我有一个工具栏,其中包含如下所示的标题:
如何消除标题文本“相机”后面的背景颜色?
这是我的布局:
<FrameLayout
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:id="@+id/recycler_view_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimaryDark">
<android.support.v7.widget.RecyclerView 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:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingTop="?attr/actionBarSize"
tools:context=".ActivityGallery">
</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/toolbar_top"
android:theme="@style/StyleToolBarWhite" />
</FrameLayout>
还有我的styles.xml:
<style name="StyleToolBarWhite">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="actionMenuTextColor">@android:color/white</item>
<item name="titleTextAppearance">@style/StyleToolbarText</item>
<item name="android:background">@color/colorTint</item>
<!-- Support library compatibility -->
<item name="background">@color/colorTint</item>
</style>
<style name="StyleToolbarText">
<item name="android:background">@null</item>
</style>
@color/colorTint
是整个工具栏的透明颜色。如果我删除样式中的background
项目,除工具栏外,我将得到所需的颜色,然后将失去“色调”颜色并变得完全透明。如何将整个工具栏的背景颜色与工具栏内文本的背景分开?
答案 0 :(得分:2)
<style name="StyleToolBarWhite">
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColorSecondary">@android:color/white</item>
<item name="actionMenuTextColor">@android:color/white</item>
</style>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_top"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorTint"
android:theme="@style/StyleToolBarWhite" />