Actionbar Back/Home Arrow Padding and Pressed State - android

I wanted to have up/home arrow button in my activity ActionBar to provide users option for navigating up. In my activity, I have set set getActionBar().setDisplayHomeAsUpEnabled(true); and also have defined parentActiviy in Manifest like this:
<activity
android:name="com.g_node.gca.map.MapActivity"
android:parentActivityName="com.g_node.gca.MainActivity"
android:label="#string/title_activity_map" >
</activity>
It works and I see a left-arrow icon before the icon in ActionBar, that onClick takes back to parentActivity. But I don't see any change in state of actionbar title or icon, when it's clicked/pressed.
How can I style that so when user clicks on that icon, it shows a pressed state? Like in following screenshot:
Moreover, How can I set the padding between the left-arrow icon and the actionbar icon ? In my activity actionbar, both are almost sticked, see screenshot below for reference:
One more thing - I'm setting this icon in my activity pragmatically using getActionBar().setIcon(getResources().getDrawable(R.drawable.icon_maps)); and icon size is 128 x 128.
Thankyou in advance for help.

You can change the background by setting the actionBarItemBackground attribute in your theme. This should be a state-list drawable which reflects states such as pressed and focused.
#android:color/transparent

Related

How to dynamically set color for back up arrow of search view in Android

In my app, I can dynamically set the color of back up arrow in action bar. But when searchView is expanded, the color of back up arrow changed back to default. I tried to set it back to the correct color by actionBar.setHomeAsUpIndicator(backArrowIconDrawable); but it doesn't make any difference.
I use toolbar as ActionBar in my app.

Hide home as up indicator on Android actionbar

I am trying to custom our home as up indicator on our Android ActionBar. I have change the icon and padding using theme style.
<item name="android:homeAsUpIndicator">#drawable/fb_back</item>
While this make the function
getActionBar().setDisplayHomeAsUpEnabled(false);
become useless. Because in some situation I want to hide the up arrow icon. However calling this leaves large space left of the home button. I am working on sdk 16, so I cannot dynamically set the homeAsUp indicator using
getActionBar().setHomeAsUpIndicator
Some one know a better solution to do this?

Android Toolbar home as up indicator material design click effect not shown

I'm working on an Android app with some Material Design features. Currently I'm trying to fix the toolbar, but I have one problem, namely: When I press the home as up arrow to go back to the parent activity, it brings me back to the parent activity but doesn't show a ripple effect (so you see that it is clicked..)
The only thing I do to set the home as up arrow is:
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
inside my activity.
Found the bug, it was the color of the toolbar. I chose a very dark green color and therefore the click/riffle effect was not visible. Changing the color to something bright fixed the problem for me..

Custom home button on ActionBar

I am using ActionBar Sherlock library. So, to change the default home button. I did this:
<style name="Theme.mTheme" parent="android:Theme.Sherlock.Light.DarkActionBar">
<item name="android:homeAsUpIndicator">#drawable/custom_home</item>
</style>
which didn't work
So, i added this too:
<item name="homeAsUpIndicator">#drawable/custom_home</item>
now its working. I am having this custom home icon/button on every ActionBar. But in 1 of my Activities i have this in code:
actionBar.setIcon(R.drawable.options_holo_dark);
When i am in that Activity, I can see the icon which i set programatically ie.., options_holo_dark. The 1 which i set in Theme ie.., custom_home is not visible. But the Icon has moved to the Right as if its giving space on the left to the icon i set in theme(though not visible).
This is what i am getting now:
So, how can i avoid that empty space on the left side of the Home Icon?
Thank You
Theme item android:homeAsUpIndicator (and homeAsUpIndicator for ActionBarSherlock) sets drawable for the up icon - that's the little arrow pointing to left that is displayed next to the app icon when you have called setDisplayHomeAsUpEnabled(true) on the action bar.
The size of the up drawable defines the left margin for the app icon (logo). By default its dimensions are 16dp x 16dp. If you put there wider drawable the gap between edge of the screen and the app icon would be wider even though the up icon is not displayed at the moment.
If you want to change the app icon (logo). Use setLogo(int) or setLogo(Drawable) method of ActionBar. Don't forget to call setDisplayUseLogoEnabled(true) too - this method toggles between displaying app icon and custom logo. Also you can define the logo in manifest in attribute android:logo of <application> and <activity> tags and set in theme that you want to use logo instead of app icon in the action bar.

Change the down state color of the Android ActionBar UP/Home button

I'm using ABS, and I basically just want to know if there is any property that will let me overide the default blue I'm getting in a button down. My application is all red, and it's a small detail that's killin me. Ideas?
The actionBarItemBackground theme attribute will allow you to change the action item selector.
If you're using it with ActionBarSherlock be sure to provide an entry with and without the android: prefix.

Categories

Resources