For my app I want to have the same behavior of the icon in the toolbar as seen in the picture. My guess is they made a white square around the icon and then set a paddingTop on the icon or maybe resized the icon?
How can I do this to only the icon? I already made some mods in my style.xml to the text in the toolbar.
Would this be the right place?
Related
In the new Gmail app, in the mail activity. The toolbar is white, and when you scroll down, the text appears under the toolbar (the toolbar is part transparent).
When I've tried to do this with alpha or color-code, the white becomes more greyish. While in Gmail, it's complete white.
How can I achieve such a design? Have anyone tried doing this before?
P.S: I'm trying to achieve this with a view, not a toolbar.
Edit: I'm talking about this entire space, toolbar+statusbar. It's complete white with opacity/transparency
(https://i.stack.imgur.com/LYD4M.jpg)
As the title says I would like to programmatically change the icon of the crosshair in the setMyLocationButtonEnabled(true) button. If this is not possible, I would like to know how to tint the icon if possible. If it's unclear which button I'm talking about here is a photo.
Edit 1: While the link provided by Zainal Fahrudin does address how to move the button, I am still unable to tint the icon itself without tinting the whole button or replace the icon. Below is what I have now. You can see the black icon on top of the blue icon in the background.
My actionbar does not use an icon or a title, this makes the click area of the "up" button very small. How can I have a larger click area without a title and icon in the actionbar?
You can put an image where the app icon would be. Just make a transparent image to the width and height for each drawable size you need and put it in the drawable folder, call the image logo (#drawable/logo). You then need to tell the activity to use the logo, it's not hard and these links should help.
http://developer.android.com/guide/topics/ui/actionbar.html
http://developer.android.com/guide/topics/manifest/application-element.html#logo
One way to do it would be to set a custom icon for the "up" button in your app theme as so:
<item name="android:homeAsUpIndicator">#drawable/your_drawable</item>
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.
I'm using ActionBarSherlock and have set an icon using android:logo in my theme. I'd like for the icon to be flush with the left side of the screen, but it always has 6px of spacing (measured using the hierarchy viewer). I've highlighted in red the part of the icon that I can't get rid of. If I set DISPLAY_HOME_AS_UP for the action bar, then the up affordance is shown as in the second image with no additional spacing.
I assume the spacing is there to keep the icon in the same place regardless of whether the up arrow present. I'm never going to show the up arrow, so I rather have the icon flush on the left.
You can set customView like this:
actionBar.setCustomView(R.layout.customActionBarLayout)
and create your own layout just as you like it