アクションバーの色を16進数のカラーコードで変更したい。アクションバーの色を変更するためのステップバイステップの手順を手伝ってください。私はAndroidを初めて使用します。色を変更するための説明付きのすべての手順を教えてください。
style.xmlファイルで独自のスタイルを定義できます
<resources>
...
<style name="MyTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<style name="ActionBarStyle" parent="@android:style/Widget.Holo.ActionBar">
<item name="android:background">HEX_COLOR_CODE</item>
</style>
...
</resources>
しかし、それは11APIレベルからのみ機能します。さらに、ツールバーを使用して背景を設定できます。
または、コードで変更したい場合
ActionBar actionBar = getActionBar(); //for app compat - call getSupportActionBar()
actionBar.setHomeButtonEnabled(true);
ColorDrawable colorDrawable = new ColorDrawable(
Color.parseColor("#0086D4"));
actionBar.setBackgroundDrawable(colorDrawable);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加