As It was suggested in one of my questions I have to use 9-patch image with gradient for listview item background.
But when I use 9-patch image, there are still problems with gradients:
9-patch, test.9.png:
But when I left transperent line 1 px height between gradient and bottom 9-patch line, that responds for horizontal content placement it's all ok, and I have good looking gradients.
9-patch image:
And closer to see transperent line:
And it's a result:
I've got good looking gradients, but there are transparent lines, that I don't need. On the image you can see black background behind list because of this line. How to draw 9-patch image in order to have good gradients and don't have "holes" in background?
I'm using actionbarsherlock for fragments.
the Draw9patch images doesn't work well with gradients you will find some diferences displaying it in several Android OS so don´t use it.
Use a GradientDrawable
Changing gradient background colors on Android at runtime
Creating Nine (9) Patch png files with Gradients
Related
How would I replicate this in Android, my general instinct would be to create a regular layout w/ a border, then have 2 layouts that contain a triangle (one the same color as the border + one that's slightly smaller but white and overlap the two), idk if there's an easier way to do that:
You can use 9patch to achieve something like you wanted.
The Draw 9-patch tool is a WYSIWYG editor that allows you to create
bitmap images that automatically resize to accommodate the contents of
the view and the size of the screen. Selected parts of the image are
scaled horizontally or vertically based indicators drawn within the
image.
A complete guideline can be found here : http://developer.android.com/tools/help/draw9patch.html
The easiest way to reach this, is to set the layout background to that image.
background="#drawable/template"
Probably you want to have the area out of the "bubble" transparent, so you will need to save it as PNG.
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.
I am using http://romannurik.github.io/AndroidAssetStudio/nine-patches.html to create a 9Patch image which is attached. . I use this is to set a drawableBottom to the TextView.But this does not stretch to the width the text view. What am i doing wrong ? This is the original image
Here are a few reasons for it to "not stretch"
Guides must only be one pixel wide, so if you want a 48×48 button, your png will actually be 50×50. Anything thicker than one pixel will remain part of your image.
guides must be solid black (#000000). Even a slight difference in color (#000001) or alpha will cause it to fail
MOST IMPORTANT: you should keep in mind that remaining area of the one-pixel outline must be completely transparent. This includes the four corners of the image – those should always be clear. This can be a bigger problem than you realize. For example, if you scale an image in Photoshop it will add anti-aliased pixels which may include almost-invisible pixels which will also cause it to fail*. If you must scale in Photoshop, use the Nearest Neighbor setting in the Resample Image pulldown menu (at the bottom of the Image Size pop-up menu) to keep sharp edges on your guides.
http://radleymarx.com/blog/simple-guide-to-9-patch/
You need to use android sdk draw9patch tool to make a 9-patch image.
you will need to define stretchable patches to image border like shown in below image border.
Dear Fellow Developers,
I've ran into the problem shown in the attached picture. We have been trying to tweak the dropdown menu's 9patch image provided by a graphics designer, but could not get it to work. The black stretch markers are not being hidden, and Android does not stretch it the way we would expect.
The device is a Nexus 7. We have tried several various image sizes, but none seemed to work. I am also attaching a copy of the 9patch.
What could be wrong?!
This happens:
Here is the 9patch
If the image has been created in a normal image editor rather than the android 9 patch tool, it could be just that its not done exactly right.
The image must have a 1px transparent border other than where the black lines are. Make sure its completely transparent and is only 1 px thick
Also I don't think you can have split lines (like you have down the left and right side of the image, I think they must be one solid line on each side)
When I set android:background="#android:color/transparent, it sets my buttons background to transparent, but the outline of the button disappears. How do I set it so that the background is transparent but there is still an outline?
You can use a custom selector that uses different nine patch image for different states of the button.
This link might be helpful
You might use this image...
I hope it helps..
One approach would be to make yourself a 9-patch that has a border but transparency in the middle.
Here is an example:
it is an 11x11 pixel square with a 2 pixel black border. If you download this png and drop it into draw9patch and add the a pixel in the middle of the left and top then include the 9patch png file in your drawables and set
android:background="#drawable/bground"
either save your 9-patch as "bground" or change that in the above line to whatever you save it as.