I need to show a rectangular icon in the ActionBar, but it resizes me to square dimensions and it becomes so tiny i can't see it.
Do anyone know a way to show it at regular rectangular size?
Thanks in advance.
Use an action view instead of a regular action item. In the layout resource you use with android:actionLayout, have an ImageView or ImageButton or something that points to your rectangular icon.
Related
I would like to blur the background of the content pane when the DrawerLayout is open. I noticed that there is the ability to change the dim color by setting setScrimColor but I would like to blur the background. Is there a way to achieve this?
The process involves the following stages:
Get a snapshot of the whole drawer layout.
Crop it to the exact size of your menu.
Downscale it quite a bit (a factor of 8 is pretty good).
Blur that image.
Have a custom view that displays part of an image right behind of
where your menu will appear.
As you slide the drawer show a larger part of that image.
Please refer this answer
Blur background of Navigation Drawer
Or you can use one of these libraries
EtsyBlur
BlurNavigationDrawer
BlurEffectForAndroidDesign
Check out this library: Blurry. it takes a View or a Bitmap, blurs it and casts it to a ViewGroup or an ImageView. So just run Blurry.with(context).capture(parentView).into(parentView); whenever the drawer is opened.
Where parentView is the container that holds everything.
I brought two nine patch images from designer for action-bar list item background. But outside of item is black.
I add images in "android:itemBackground".
The below images have shadow effect.
I think the image is wrong because it has margin.
I wonder what is exact cause?
thank.
Image1:
Image2:
I think the designer intend to make shadow effect by using bg image. Because other app's overflow menu have shadow effect. But the effect is shown by framework. So I used an color drawable as background.
Basically, I wanted to have a button where text and icon stay in the middle of the button at all times. The Button has match_parent width and center gravity. I tried to use drawableLeft but that put icon on the left most of the Button and not next to the text.
So I'm trying to create 9-patch image as shown in the image above. Basically, I want all the text to stay in blue box with the cyan rounded rectangle (icon) next to it. The stretchable area is in red. However I just can't make it as the content area always overlap the icon.
Is this possible with 9-patch? Or should I wrap Layout around the TextView and use that as a button instead?
By the way, the included image is just to show what I plan to do. The actual image will be in other colors and without all the red.
When you create a nine-patch image, you put some black lines on the right and bottom of the image. These lines define the region that will be use to place the content inside of your image.
Here is an example :
It will look like this :
My Drawables have a transparent background with an white icon in the middle. What I want to do is programatically color ONLY the white part and leave the transparent pixels untouched.
I've tried lots of different methods but I always end up with a Drawable that is completly colored.
Does anyone know how to go about this?
Cheers
I don't know whether it will suit your requirement, but please split the one image with two, one full background transparent image and other is single white image icon and put this on the centre of the layout and change only that imageicon's color.
I'm trying to set an image as background of the Sherlock Action Bar, but even if the it's 720 x 112 px, it seems like the image doesn't stretch.
The white part is still part of the Action Bar, as the triangle is set in the correct position and the button on the right, has different margins on the top and at the bottom.
Do I need to make it a 9patch image? Not sure why it doesn't work..
I'm setting the background with a getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.topbar));
Thanks a lot in advance for the help!
Did you put your image in hdpi or mdpi? Try switching around. Ultimately, use draw-9-patch and safe yourself a lot of headache.