My problem is a whitespace that creates itself when I put an image in the background.
I made a new icon set. Put an image there and cropped it so it has no white border. And when I create a new image view it works it has no border around itself. But when I put it as a background on repeat it creates a whitespace.
It looks like this:
I cant post an image so look here: http://i.stack.imgur.com/AwNiz.gif
I am using a relative layout and I have created a file drawable and put an xml file in it in which I have this code:
<?xml version="1.0" encoding="utf-8"?>
<bitmap
xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/im"
android:gravity="center"
android:tileMode="mirror"/>
I tried it with 3 different pictures and it always does the whitespace when put on repeated background.
I wanted the background to simply connect without any whitespace.
Thanks in advance :)
I am using Eclipse.
What happens if you create a 9.png file and allow it to stretch to the edges? Looks like your bitmap is smaller than the space.
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 need to create a seekbar that has custom background and custom thumb image. The problem is that background is kind of complex and i can't really create nice 9patch out of it.
Seekbar should have 3 values (0,1,2) and each value is represented by an image. Thumb should be centered around image of current value. Picture shows the seekbar with value "1" selected:
Problems I had were:
to create a 9patch from background and keep edge and central image from moving / scaling.
create a thumb that will always be in right scale compared to images representing different values.
How can I do this?
Edit
In short: I'm having troubles to make sure seekbar fills entire width of the screen (regardless of screen size), but again to make sure "ring" (thumb) will always fit perfectly around each "value" image.
I am not quite sure I understand your problem, but you can create a bitmap xml to avoid resizing on your background pictures:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/mydrawable"
android:tileMode="disabled"
android:gravity="top" >
</bitmap>
If you are having troubles with arranging the items/pictures, you can always play with a relative layout's diferent params.
In my eclipse, when ever I have a scrollView and a background image set up at the same time, my background image stretches vertically. I would like it not to stretch but repeat all the way down the ScrollView.
Please help
Create a XML file within the drawable:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/my_image"
android:tileMode="repeat" />
than you can use this file as your drawable, and it will be repeated
Note that there is a bug related to repeat (android 3.0 and bellow), when used in a listview
see XML drawable Bitmap tileMode bug?
My designer has given me the following layout (a little bit changed to protect my business :)
Now, I am facing a lot of doubts as how I can incorporate every element to my android layout.
As you can see, the background has a light noise to it. I tried creating a 9patch from it, but when loading in Android, I completely lost the quality of the imaged. It stretched out weirdly. Should I have one background for the different resolutions (ie. mdpi, hdpi... ) or can this be achieved with 9 patch
What to do with the button? I tried saving the button (which in photoshop it is a group) into a new image and saved it as a PNG. When loading in the layout with a ImageButton and trying on my phone, the button is just too big. How can I guarantee the size of the button on different type of screens? Will I need different sizes of this button for different resolutions (mdpi... ) and if so, how will I know what is the size of this button for a hdpi resolution, or for a mdpi resolution? Or maybe I should force the width and height of the button to a value like 60dp, but that doesn't sound right to me. I understand I can create a shape and apply it to the background of the button but, what about the Facebook button? I imagine that, in that case, I will need a ImageButton with the PNG as background.
I know this is late as hell but hopefully it will help others.
1) Ask your designer for a repeatable image that you can tile for the background. I don't see any reason why it couldn't be tiled. To tile an image make an xml file of type drawable for each of the generalized dpi folders. Put this code in the xml file:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="#drawable/piece_of_the_background_that_can_be_repeated"
android:tileMode="repeat" />
Set the background drawable to this xml file.
2) Set a 9patch image as the button background and use this custom textView for the text. Use the innerShadow attribute to get the shadow effect your designer shows.
I am trying to set a 9-patch image as the background for one of my activities but it is stretching unescessarily making everything get all wierd. I used draw9patch to create it and added one pixel to the bottom left and one pixel to the top right. I then save it into my drawables directory as intro_bg.9.png. I want to stretch the very bottom and stretch the far right side but only if it has too. If it doesn't then I would like it to stay in tact.
When I set it as the background of the parent layout however it stretches it both horizontally and vertically and it doesn't even show my buttons when I run it on my droid.
I've done the Google searches but there is no good info on how to get something like this working. What am I missing?
I have also tried some other configurations including using the padding sides(right and bottom) but that gave the same results.
Thanks
Code to set as background:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/intro_bg"
>
Looks like:
Should look like:
Your image is just too big to fit the layout. If you want it to be contracted you need to paint a line on the top and left borders -- the line marks region which will be contracted or stretched. I guess right now you have just dots on the borders.
Second option is to set the image as activity background, then it will be fitted in the screen. To do this add styles.xml to res/values folder:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ExampleTheme" parent="android:Theme">
<item name="android:windowBackground">#drawable/intro_bg</item>
</style>
</resources>
Then apply the theme to your activity at the manifest. The intro_bg drawable even doesn't need to be a 9-patch.