Ich entwickle eine App, in der ich eine Aktivität habe, die als "AboutPreference" bekannt ist, die PreferenceActivity
erweitert und ich eine Symbolleiste in postCreate()
Methode hinzugefügt hatte. Problem ist, dass ich "homeAsUpIndicator" -Farbe von Schwarz zu Weiß ändern möchte. Wie kann ich tun, dassWie ändert man die Farbe von HomeAsUpIndicator in Android?
Code: -
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
LinearLayout root = (LinearLayout)findViewById(android.R.id.list).getParent().getParent().getParent();
Toolbar bar = (Toolbar) LayoutInflater.from(this).inflate(R.layout.about_toolbar, root, false);
root.addView(bar, 0); // insert at top
bar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
Symbolleiste
<android.support.v7.widget.Toolbar
android:id="@+id/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:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
app:navigationIcon="?attr/homeAsUpIndicator"
android:minHeight="?attr/actionBarSize"
app:navigationContentDescription="@string/abc_action_bar_up_description"
app:theme="@style/ToolTheme"
app:title="About Us"
tools:ignore="PrivateResource"/>
und hier Stil ist
<style name="ToolTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/white</item>
<item name="android:textColorSecondary">@color/white</item>
<item name="android:textColorPrimaryInverse">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:homeAsUpIndicator">@color/White</item>
<item name="colorPrimary">#F5560A</item>
<item name="colorPrimaryDark">@color/accent</item>
<item name="android:navigationBarColor">@color/accent</item>
<item name="colorAccent">@color/accent</item>
</style>
http://stackoverflow.com/questions/26439572/how- angeben to-style-the-drawerarrowtoggle-from-android-appcompat-v7-21-library – Raghunandan