Android Background Image - Unwanted Horizontal Lines - android

My activity's background is showing up with some horizontal lines on both emulator and actual device that don't show up in the orginal image on my computer.
I am using GIMP to edit my background images. I have tried both .jpg and .png format.
Does anyone know why these horizontal lines are showing up?
The lines are hard to see from this emulator screen, but appear much more prominently on the actual device. Any help is appreciated.

It is really hard to see the problem on the screenshot you posted, but it looks like it is compression related. You should check out my answer to this question.

Not sure of my answer but you should try to have a multiple of 2 for image's height and width.

Related

Android 9-patch image usage

OK, I've read a lot of tutorials and even downloaded some examples, but for the love of Stackoverflow, I can't get my image to stretch like I want it to and I'm hoping that someone can help me out here.
I create an image that is to be the background of a button object in Android. Here is the image:
Now, I'd like for it to stretch to the desire size of the button, whether the button is 50x50dp or 200x100dp. One thing I don't want is the border to stretch as it will look distorted, so I want to specify not to include the border, but stretch everything else to the desired size of the button.
Can someone please show me where the black lines need to go in order to achieve my goal? Do I have to change my original image in order to achieve my goal?
Thank you in advanced.
David
It's very simple using this tool Android Asset Studio: Simple 9-Path Generator. Although no matter how you do it you will have stretching and distortion due to the textured (non-patterned) background. I would stay away from that style both personally and for usability.

flash cs5 transparent png issue on android screens

I am creating images in Photoshop with a transparent background. I am calling them into flash dynamically with actionscript 3 but the transparency has a white ghostly look to them. I can see the boxes move around on my ANDROID devices.
I found this tutorial and it helps: http://kb2.adobe.com/cps/128/tn_12804.html#main_Known_issues_with_transparent_bitmaps
HOWEVER I want to import the images dynamically and not have to bring each image in to flash and fix it. Any ideas on what settings will work when exporting from photoshop?
I found a "WORK AROUND" solution.
I created a transparent PNG TO COVER THE ENTIRE SCREEN. I loaded it in the second level
above the background image. There may be a ever so faint "ghosting" look but I can't tell by looking. One thing for sure it removed the boxes around the other transparent PNG files I am loading in. So that's great!
Please let me know if this helped you. Thanks
-Ed Vizenor

Using non simmetrical button background images

Id like to have a button shaped like a cloud. A 9 patch might be unusable since every time I create large borders around my cloud image, I get warnings about "bad patches" in the 9 patch tool. Using 1px borders gives weird results too 1. When replacing my resource with the btn_default from api 4 I get expected results, ruling out xml issues.
Without using 9 patches, wrap_content seems to work no more, growing the image to 100% width regardless of content. The 9 patch used is shown below.
I wouldn't mind some distortion, as long as content does not overflow. What would be the best solution?
I am not allowed to post images yet, apparently. Please see
zip containing screenshots and 9patch
Nice question.
I think there is no way to use those images and you might need to change them, but I will leave you some tips or things I would try:
To avoid overflow you will need to define the fill area. You can try just adding a fill area but not a scale area. If this works, you will have the cloud image with the text inside it.
Remember that 9patches scale up and not down.
Here is a link with a very good explanation of how everything works.
If nothing worked so far I would ask the designer to create a new image resource with a stretchable area. For instance, having cloud shape just in the corners.

Creating a 9 Patch with repeatining pattern

iam stuck with the creation of a nine patch for a progressbar background.
It has a repeating pattern like a ruler-scala and that given me headache.
here is a image of what i want(at the bottom) and what i have (top).
can someone give me a hint how to acomplish my goal?
edit: or is it generelly possible to do this with a 9patch?
my other attempt was to make a with android:tileMode="repeat" but there i get problems with the height of my image (repeating in the second line), i need something like repeat-x.
Thanks in advance
edit2: ok i managed to do my repeating 9patch by stretching the whole repeating pattern, but its not ideal :(
You seem to be overestimating the power of 9-patches. The most you could do is have a ruler image with expanding space between the ticks. You can't, however, make a 9-patch that automatically tiles parts of your image.
On the other hand, if you create a BitmapDrawable programatically, you can set the tile mode separately for the X and Y axes.
I used to do this in my webview project using border image which provides both options (repeat, stretch, fill).
As webview has kind of it's own problems in android (mostly fixed element) I decided to be more android for the next project and I found out that it's not possible to have the repeated border using 9Patch. It's so awkward as it's needy but not implemented.
In a word android development area makes me crazy, one option here one option there is a usual thing here.

ImageButton does not display a particular drawable

This is rather a funny problem I have ever come across,
I have a table layout with 9 image buttons, 3 per row. Every ImageButton has a different image associated with it. I have set the background of the image button to transparent (#00000000). Now here is where the funny stuff happens, One of the images doesn't show up on the emulator (Gingerbread) as well as a device running Froyo. The layout editor shows all the images in place.
Here are some more stuff:
I used a RelativeLayout instead of a TableLayout, the same issue persists.
I changed the position of the image (used it on different buttons) and still it doesn't show up.
When I use a different image they show up, but when I use this particular image it won't.
All images have the same resolution (90x72) and density (72ppi)
All the images are in the the drawable-mdpi folder.
Any pointers?
EDIT
Turned out to be a bug and this issue has been resolved. Please check this link.
Do you still have the problem. I had a similar bug - a particular drawable was not being displayed, no matter in what `ImageView`.
Is it the case that your image is the first (alphabetically) in the drawable folder? For some strange reason there is a problem with the first drawable, I've solved my problem by adding a dummy drawable in first place. Still I'm very curious where the actual problem is.
Hope that helps! And I'm looking forward for any further explanations :)
I can confirm adding a dummy image which displays first alphabetically is a fix.
I had an image (titled about.png so of course near the top of the drawable folder) which was not displaying when the test device used was mdpi.
In my case, though, the image was not the first in the directory. I actually had an image which alphabetically displayed first called about_icon.png - which oddly was displaying fine. Additionally, the hdpi version of the image was displaying fine within an hdpi device.
I added a dummy placeholder image called "aaaa.png" and now the mdpi about image displays fine in device.
Very strange, and honestly a pretty lousy bug.
Try to use android:src="#drawable/my_resource", instead of app:srcCompat="#drawable/my_resource".
This post is fairly old however I was experiencing a similar issue. Running 4.4.2 my imagebutton's would show some images correctly however others it would change. For example my white "ic_camera.png" would look like this....
What appeared to randomly turn images into their dark counter part.(I double and tripple checked that I put the right color in) All images came from the Android Icon pack. I tried deleting and copying back all images multiple times to no avail. Finally I just changed the naming convention, dropping all of the "ic" and "_" so that the images where all simple words and lower case. ie... "camera.png", "upload.png", and "newimage.png"
BINGO!
Very strange but a simple fix. Hope this helps someone else!
Cheers!
For anyone coming to this question and the answer does not work, your image size might not cater to the devices target size... click here to get the right sizes.
For me it was a different issue. The images did show on nexus4 and nexus5 but not nexus3. I scaled down the images from 2000px width to 1000px width and worked like a charm.
When you do it in DESIGN PANEL you get something like this:
<ImageButton
android:id="#+id/translate_button"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:srcCompat="#drawable/translate_button"/>
Change the last line manually into:
<ImageButton
android:id="#+id/translate_button"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/translate_button"/>
It worked for me.

Categories

Resources