ActionBarの背景と文字を変更してみよう!
よくあるこんな感じのActionbarの背景を変更してみます。
必要なもの
・colors.xml
色情報を格納するためのXMLファイルです。
格納する場所はres/valuesに入れます。
valuesの中には他にdimens.xmlやstrings.xmlといったファイルが入ってると思います。
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="start_color">#e56200</color>
<color name="end_color">#FFE1CC</color>
</resources>
・gradation.xml
Actionbarに使う背景色です。
drawableのフォルダの中に格納します。
gradation.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:startColor="@color/start_color"
android:endColor="@color/end_color"
android:type="linear"
/>
</shape>
色はこんな感じです。
・styles.xml
アプリのデザイン(スタイル)を決めるXMLファイル。
一言で言えばCSSみたいなものです。
styles.xml
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="android:Widget.Holo.ActionBar.Solid">
<item name="android:titleTextStyle">@style/ActionBarTitleStyle</item>
<item name="android:subtitleTextStyle">@style/ActionBarSubitleStyle</item>
<item name="android:background">@drawable/gradation</item>
<item name="android:backgroundStacked">@android:color/white</item>
</style>
<style name="ActionBarTitleStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textStyle">bold|italic</item>
<item name="android:textColor">@android:color/white</item>
</style>
<style name="ActionBarSubitleStyle" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle">
<item name="android:typeface">monospace</item>
<item name="android:textColor">@android:color/white</item>
</style>
</resources>
うまく適用できました!٩('ω' )و
Author And Source
この問題について(ActionBarの背景と文字を変更してみよう!), 我々は、より多くの情報をここで見つけました https://qiita.com/fumi_042/items/ac7f983c4bfc5724bb10著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .