If you want to apply style for actionbar then add
values-v11
is the values of the API version 11, and values-v14
is the values of the API version 14 in the res folder/ when your minSdkVersion is less than 11.<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" />
Using Themes, getting space between homeAsUpIndicator and App Icon is not working but it is possible through programatically.
android:homeAsUpIndicator : Specifies a drawable to use for the 'home as up' indicator.
programatically:
setDisplayHomeAsUpEnabled(true) shows the "<" on the action bar.
Style:
android:homeAsUpIndicator allows to change the icon
<item name="homeAsUpIndicator">@drawable/custom_home</item>
Solution:
Access the homeAsUpIndicator from the app by calling the android.R.id.home.
Change padding so that we will get space between homeAsUpIndicator and App Icon.
((ImageView) android.R.id.home).setPadding(7,0,7,0)
Hi,
ReplyDeleteNot working as you said.
Would you please post full snippet of code.
I extended my activity with SherlockFragmentActivity.
final ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setHomeButtonEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#08A3F5")));
actionBar.setLogo(R.drawable.menu_dark);
Now I want to set padding at left side of setDisplayHomeAsUpEnabled. I do not want to show the < icon so I have
style name="AppBaseTheme" parent="Theme.Sherlock.Light"
name="homeAsUpIndicator" --->@null
name="android:homeAsUpIndicator" -->@null
Thanks.
The code is shown not for sherlock library.
DeleteOne question
In your code, you haven't set padding. then how come, it will work?
Use the below code, set padding for the home icon in onCreate of your activity.
((ImageView) android.R.id.home).setPadding(7,0,7,0)
In styles or themes, we can't give padding for action bar.
ImageView view = (ImageView)findViewById(android.R.id.home);
ReplyDeleteview.setPadding(7,0,0,0);
this works fine :-)
nice it worked for me.
ReplyDeleteImageView view = (ImageView)findViewById(android.R.id.home);
view.setPadding(7,0,0,0);
this works fine :-)