试图使工具栏中的文本背景透明
Trying to make background of text within a toolbar transparent
我有一个包含如下标题的工具栏:
如何去掉标题文本后面的背景色 "Camera"?
这是我的布局:
<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
项目,我会得到我想要的,除了工具栏然后失去 "tint" 颜色并变得完全透明。如何将整个工具栏的背景色与工具栏内文本的背景色分开?
<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" />
我有一个包含如下标题的工具栏:
如何去掉标题文本后面的背景色 "Camera"?
这是我的布局:
<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
项目,我会得到我想要的,除了工具栏然后失去 "tint" 颜色并变得完全透明。如何将整个工具栏的背景色与工具栏内文本的背景色分开?
<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" />