I have setup the following AppBarLayout
+ TabLayout
for the main activity of my Android app.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.LinearLayout
android:id="@+id/main_layout"
android:orientation="vertical"
...>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
...>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
... />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabGravity="fill">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
...
Basically it looks like this:
The question is: How can I pragmatically change the color of the home icon (the hamburger icon in the picture)?
Setting the color within my the XML syltes is no problem:
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorSecondary">#ff00ff00</item>
...
</style>
But how can I change this pragmatically at runtime? There seems to be no setter for textColorSecondary...
As far as i know, I do not believe you can set the style programatically. What you can do, however, is changing the style ( while keeping the same values) but only changing textColorSecondary
value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.