【发布时间】:2017-09-26 13:59:44
【问题描述】:
我想完成以下任务
- 删除默认工具栏
- 构建自定义工具栏
- 更改工具栏中的默认标题、标题文本颜色、标题文本对齐方式
我成功删除了默认工具栏,但是在构建自定义工具栏时我无法删除
- 更改标题文本颜色
- 改变titleText对齐方式
我尝试了在堆栈溢出时为上述问题提供的现有解决方案,但在我的情况下似乎没有任何帮助
这里是 toolBar.xml 文件
enter code here
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.toolbar
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/toolbarC"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
android:theme="@style/Mystyle"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:titleTextColor="#ffffff">
</android.support.v7.widget.toolbar>
这是我的主要 xml 文件
enter code here`
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:layout="http://schemas.android.com/apk/res-auto"
android:background="#3dcc24">
<include
layout="@layout/clubs_tool_bar" />
</LinearLayout>
这是我的 styles.xml 文件
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="ColorTemp">@color/ColorTemp</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="Mystyle" parent="ThemeOverlay.AppCompat.ActionBar">
<item name = "android:textSize">30sp</item>
</style>
</resources>
这就是我的屏幕的样子
【问题讨论】:
标签: android android-layout android-toolbar