1) How to change the color of the small arrow on the left.
2) How to change the color of the three points on the right and how to replace the three points with my own icon.
3) How to make the "trade list" of the 4 words in the center display.
As shown in the figure
First set theme to Appcompat.noactionbar.
(1) toolbar can be set Setnavigatetionicon, an icon will be passed in to replace the left-most small arrow, but you need to implement its own action.
(2) Add in your own theme definition
<item name= "Actionoverflowbuttonstyle" > @style/overflowbuttonstyle</item>
<style name= " Overflowbuttonstyle "parent=" @android: Style/widget.actionbutton.overflow ">
<item name=" ANDROID:SRC " > @drawable/float_button</item>
</style><pre><code class= "Language-text" > You can change those three points. </code>
(3) It is my personal practice not to use settitle, but to insert a TextView in the toolbar XML definition and then set its layout_gravity to center, which is in the middle.
The other arrow shows the code.
Getsupportactionbar (). Setdisplayhomeasupenabled (true);
Want to respond to this return time. In fact, onoptionsitemselected ()
<pre name= "code" class= "Java" > @Override public through android.r.id.home
monitoring Boolean onoptionsitemselected (MenuItem item) {
if (item.getitemid () = = Android. R.id.home) {
onbackpressed ();
}
return true;
}
After entering a child activity from the mainactivity, how do you make a return arrow appear to the left of the toolbar and return to the mainactivity after clicking? It's really simple, just two lines of code.
Add activity to add the return button to the Androidmanifest.xml in the toolbar property
android:parentactivityname= "Com.example.myfirstapp.MainActivity"
<application ... > ...
<!--the main/home activity (it has no parent activity)--
<activity
android:name= " Com.example.myfirstapp.MainActivity "...> ...
</activity>
<!--A Child of the main activity--
<activity
android:name= " Com.example.myfirstapp.DisplayMessageActivity "
android:label=" @string/title_activity_display_message "
android:parentactivityname= "Com.example.myfirstapp.MainActivity" >
<!--Parent activity Meta-data To support 4.0 and lower-
<meta-data
android:name= "Android.support.PARENT_ACTIVITY"
Android : value= "com.example.myfirstapp.MainActivity"/>
</activity>
</application>
And then add a line of code to the program to implement the
@Override public
void OnCreate (Bundle savedinstancestate) {
...
Getactionbar (). Setdisplayhomeasupenabled (true);