【发布时间】:2016-11-30 09:59:35
【问题描述】:
在我的应用程序中,有一个活动,其布局如下所示。我遇到的问题是,当该活动开始时,操作栏变得不可见,CoordinatorLayout 占据了所有屏幕。 我想要做的是 actionBAr 应该是可见的。我的应用程序的操作栏看起来像下面“操作栏”部分中显示的图像。
为了解决这个问题,我做了以下操作:
我在styles.xml 文件中添加了“FloatingButtonTheme”,如下面的“styles.xml”所示。在清单文件中我添加了以下代码:
<activity
android:name="x.xx.xxx.activity.ListeActivity"
android:theme="@style/FloatingButtonTheme">
但我得到的结果是,活动占据了屏幕上的所有空间,浮动按钮出现,但操作栏永远不存在。
请告诉我如何强制显示我的操作栏,如下图所示?
其实这个问题只有在我使用的时候才会出现
活动布局:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
tools:context=".activity.VersiecherungsListeActivity">
<include layout="@layout/versicherungslisteactivity_vers_view" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/versicherungslisteactivity_fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="10dp"
android:src="@android:drawable/ic_input_add"
app:backgroundTint="@color/light_orange" />
</android.support.design.widget.CoordinatorLayout>
操作栏:
风格:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="FloatingButtonTheme" parent="Theme.AppCompat.Light.DarkActionBar">
</style>
【问题讨论】:
-
发布此布局代码
versicherungslisteactivity_vers_view?? -
@Ironman 好的,我添加了它
-
你会删除 android:fitsSystemWindows="true"
-
@user2121 add
ToolbarasRavish Sharma回答如果你没有添加在Activity中。
标签: android android-actionbar android-coordinatorlayout android-actionbar-compat android-actionbaractivity