工具栏在某些设备上是不可见的
问题描述:
我有一个相当简单的布局,并使用附加功能为工具栏的显示/隐藏设置动画。我使用的程序兼容性和工具栏...工具栏在某些设备上是不可见的
问题
一个人报告说,在顶部工具栏永远不会显示。任何想法为什么?可能是什么原因?它的正常工作我的手机和其他人...
功能
public void showHideToolbar(boolean forceHide, boolean animate)
{
L.d(this, "showHideToolbar: " + mShowToolbar);
toolbar.clearAnimation();
toolbar2.clearAnimation();
if (mShowToolbar || forceHide)
{
if (animate) {
toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
toolbar2.animate().translationY(toolbar2.getBottom()).setInterpolator(new AccelerateInterpolator()).start();
}
else
{
toolbar.setTranslationY(-toolbar.getBottom());
toolbar2.setTranslationY(toolbar2.getBottom());
}
mShowToolbar = false;
}
else
{
if (animate) {
toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
toolbar2.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start();
}
else
{
toolbar.setTranslationY(0);
toolbar2.setTranslationY(0);
}
mShowToolbar = true;
}
}
布局
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/flMain"
android:background="?attr/main_background_color"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
app:theme="?actionBarThemeStyle"
app:popupTheme="?actionBarPopupThemeStyle" />
<android.support.v4.view
android:id="@+id/vpSlides"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/bottom_bar_background"
android:elevation="0dp"
android:layout_alignParentBottom="true"
android:gravity="top|start"
app:theme="?actionBarThemeStyle"
app:popupTheme="?actionBarPopupThemeStyle" >
</android.support.v7.widget.Toolbar>
</RelativeLayout>
答
这似乎是,即使你犯了一个工具栏的动作条,你必须尊重xml中的布局排序。 setSupportActionBar
不会带来操作栏上的主要布局的顶部...
所以简单的解决办法是在工具栏重新排序的内容下是...
我从来没有广告的问题又为常我显示工具栏下方的内容,在这里我不想那样,因此面临问题