我想为我的应用创建一个主题,如下所示:
为此,我在styles.xml
文件
<style name="TestAppThemeTopbar">
<item name="android:background">@drawable/gradient_topbar</item>
<item name="android:text">@string/topbar_title</item>
<item name="android:gravity">center</item>
<item name="android:textColor">#6D929B</item>
</style>
<style name="TestAppTheme" parent="android:Theme">
<item name="android:background">#F5FAFA</item>
<item name="android:windowTitleSize">81dip</item>
<item name="android:windowTitleBackgroundStyle">@style/TestAppThemeTopbar</item>
</style>
gradient_topbar
是一个xml文件,其中包含以下内容:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- Gradient Bg for listrow -->
<gradientTopbar
android:layout_width="match_parent"
android:layout_height="81dip"
android:layout_weight="1"
android:startColor="#B7AFA3"
android:endColor="#E8D0A9"
android:angle="270" />
</shape>
我将主题添加到清单文件中。并将主题应用于项目。现在在Graphical Layout
的{{1}}中,主题的外观如下:
我还需要做以下事情:
我做错了导致前三个问题?怎么解决?如何做到第二个?
修改
这就是我将主题添加到清单文件的方式:
fragment_main.xml