<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:tileMode="repeat"
android:src="#drawable/header_background">
</bitmap>
I am using the following as a background for the action bar. The code gives me the following image:
How is there gaps on the image ? Can someone please help.
header_background:
Modify the image to remove the shadow outline. It needs to be a flat image, so that when it is tiled, it will be visually seamless.
See this example:
Also, you might be interested in this post regarding tiling along the x-axis.
remove the android titlemode = repeat
Can you not just make this a 9patch that scales like you are looking to do with horizontal tiling?
Related
So I would like to create a checkered effect with my bitmap. So I am using this very small pixel grey color png. I need to add a margin or padding before it's repeated but I'm unsure how to do this. Any help will be welcome as I have just started learning Android development.
What it's doing right now is repeating the entire image, filling the window with one color.
Background.xml
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/bg"
android:tilemode="repeat">
</bitmap>
In my Activity Main XML I'm including the above XML
android:background="#drawable/background"
If I understand You correct and You want to make an effect like this
Using a single grey pixel and adding margin to next before repeating, it will be much easier if You don't use:
But just a:
With a pattern like this, You can repeat an image and You will get a checkered effect.
I am creating a tiled background. I read may posts about using bitmap xml with repeat tile. The tile I am using is has a diamond shape. So when I do the tile there are black gaps in between the tiles.
I hope I am explaining myself. How can this be done so the whole screen is covered tiles (ie sides touching each other not only vertices)
Thank you
I am using this image
And this is the code
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/tile"
android:tileMode="repeat"
android:dither="true" />
What you want to achieve is impossible yet.
Images are always rectangle shaped. You see it as diamond just because corners of image are transparent. But it still has rectangle shape.
This is what actual image should look like,
But black corners are not visible because it has transparency set at the corners. That's why it looks like,
If your image had no transparency then your tiled background would look like,
And because of transparency at the corners it is looking like,
And what try to achieve is to overlap that blank space with diamond (because you say image is diamond shaped) which is not possible because images are always in rectangular shape.
And there's no library written yet which can ignore the alpha (transparency) of the image.
You should either use opaque image or leave the space blank in tiled background (if you use this image).
Perhaps change the way you are tiling your image? Maybe your initial image that you're tiling looks like this <> but maybe you want it to look like this >< ? It would be more helpful if you posted your image. Can you also post the code you're using to tile the bitmap?
I would like to have a pattern along the edge of a view. For this particular case, I would like it to be a jagged edge (like tearing parchment paper or tinfoil out of a roll). I would prefer a more general solution - perhaps at some point I would like waves along the top of a view, or a binder coil down the side. I would prefer to have some kind of repeating image rather than stretching an image.
Edit:
I would like a the pattern to occur just around the edge of the view (perhaps only on one edge). For example, a tear mark on the bottom or top of a receipt. The tear should not repeat up or down the image, just at the bottom edge.
Create a drawable (pattern_tile.xml) with the root element of a <bitmap>. Like this for instance:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="#drawable/bgnoise_lg"
android:tileMode="repeat" >
</bitmap>
And the drawable image used in the code above is:
Then, in your XML, you set it like you set the usual background using this attribute:
android:background="#drawable/pattern_tile"
Oh. Almost forgot, I put these two files, in the drawable-nodpi folder. I don't want Android to ever scale the image for me.
Obviously, since your question is a little vague, you will have to use your own image instead of the example I have posted, play around with it a bit till you get the result that suits your needs.
NOTE: Such a thing is typically done when you have patterns that should repeat instead of filling up the screen or stretching. So make sure the image you use is such a pattern that can repeat and not look out of place.
I have a 9-patch image file which looks like this:
When I use it it appears like this:
What I actually wanted to achieve is the complete dot in the center repeated instead of stretched. I hope that it's possible.
I think it's not possible using 9-Patch to make repeated patterns (only stretching certain area), perhaps you could find more about it in official documentation
...
Correction: If you want the orange dots to repeat, you will not succeed using 9 patch. 9 patch can only stretch the part you told it to stretch and leave untouched, the remaining areas. There is no repeat mode with 9 patch PNG.
You might want to look into Bitmap class. There is a tileMode you might be able to use for your problem here.
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/stripe_bg"
android:tileMode="repeat"
android:antialias="true"
android:dither="false"
android:filter="false"
android:gravity="left"
/>
First make sure you save your 9 patch image as your_image_name.9.png and store it in the res/drawable folder. Then in your xml just set the layout background with-- android:background="#drawable/your_image_name" and that should work. If it's still not working can you post your layout xml?
I have an image that has a fairly large shadow around it and its background is transparent. I have saved it as a PNG file from photoshop and am using it in an ImageView through xml. This results in the shadow having a banding effect and just doesn't look nice. Not too sure what to do...
Just add
// set 32 bit window (draw correctly transparent images)
getWindow().getAttributes().format = android.graphics.PixelFormat.RGBA_8888;
in onCreate(...)
http://www.curious-creature.org/2010/12/08/bitmap-quality-banding-and-dithering/
I can't remember what this property was used on, but I think it was an ImageView.
Try using android:dither="true" as part of the ImageView xml declaration and see if that helps.
I can't remember where I read it, but on the developer site somewhere there was this suggestion for fixing gradient banding; it might help with the shadow as well. Right click the effects icon on the layer that has the shadow, and click "Create Layer" to make a separate layer for the shadow. Then apply an "Add Noise..." filter to the layer with the following settings:
(in case the image ever disappears, Amount:0.5%, Uniform, Monochromatic)