Android Development Change the icon of the return button

Source: Internet
Author: User

Many Android apps have a Back button in the top left corner

By default, ADT will default to a return icon

And as a lot of development needs are required to customize a new icon

Found 2 ways to change on Android's website


1.

Setting in the Java Code environment

ActionBar = Getactionbar ();        Actionbar.setdisplayhomeasupenabled (true);        Actionbar.sethomeasupindicator (R.drawable.back);


If you have an error message, call requires API level: Android.app.actionbar#sethomeasupindicator

Indicates that the current minimum API level is less than 18 then refer to the second method.


2.

Add a style to Styles.xml

<style name= "Style_titlebar_normal" parent= "Theme.AppCompat.Light" >       <item name= "Android: Homeasupindicator "> @drawable/back</item> <!--back icon-->    </style>  


The style is then set in the Androidmanifest.xml in the theme of its activity


<activity            android:name= "com.logic.activity.Activity1"            android:theme= "@style/style_titlebar_normal"            >        </activity>

This approach does not require the API level to be slightly more complex







Android Development Change the icon of the return button

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.