black dots on 9patch image - android

My app is showing the 9patch black marks. Why could it be?
That's my picture:
You can see the small black dots. The file name is "filename.9.png".
I am using the 9patch program that comes with android sdk.
That's my code:
<ScrollView
android:id="#+id/left_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="#+id/pic_coupon_calender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#drawable/pic_coupon_news" />
</RelativeLayout>
</ScrollView>
The background is "pic_coupons_news.9.png".
What could be the reasons for such a thing?
Thanks!

It happened with me once too.
Just clean your project and rebuild. This should resolve the defect.

Related

Text color is changing in Android Studio but not showing on phone

I have browsed through a few places but can't find anything "exact" to solve my issue. I set code in Android Studio and the display showed my top text as orange and the bottom text as blue...which is what I intended. When I tried running it on my phone, the text color did not show as it does in Android Studio. (Just is gray text on my phone)
This is a simple bit of code as I'm currently learning from Udacity and a couple other places. Any ideas why code would show as working on Android Studio but wouldn't work on the phone? (especially when dealing with something as simple as text color?)
The code is as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.saoiray.happybirthday.MainActivity">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="I'm awesome! Birth of a developer (^_^)"
android:textColor="#FF5722"
android:textSize="32sp" />
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Oh yeah, Stephen is awesome!"
android:textColor="#3F51B5"
android:textSize="32sp" />
<ImageView
android:id="#+id/androidparty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:src="#drawable/androidparty"
tools:ignore="ContentDescription" />
</RelativeLayout>
I had the same problem, and i disabled the "High contrast fonts" from the Settings-> Display -> Visibility enhancements , of the phone and now the textColor appears like in Virtual Device

Adding a background image to RelativeLayout hide all others elements

I have a simple XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity"
android:background="#drawable/login_background">
<LinearLayout
android:orientation="vertical"
android:layout_width="320dp"
android:layout_height="160dp"
android:layout_alignParentBottom="true"
android:layout_marginStart="218dp"
android:layout_marginBottom="25dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText"
android:textColor="#color/surtimax_gris_texto"
android:layout_gravity="center_horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textStyle="bold"
android:hint="#string/login_edittext_user_text"
android:textColorHint="#color/surtimax_gris_texto" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/editText2"
android:background="#drawable/login_edittext_background"
android:textColor="#color/surtimax_gris_texto"
android:layout_gravity="center_horizontal"
android:layout_marginTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textStyle="bold"
android:hint="#string/login_edittext_pass_text"
android:textColorHint="#color/surtimax_gris_texto" />
</LinearLayout>
</RelativeLayout>
The problem is: neither in emulator or real device is showing LinearLayout and EditText when RelativeLayout has a background.
If I just remove the background everything works fine... it's weird.
Not error logs about app.
minSdkVersion 17
targetSdkVersion 22
UPDATED
Its working with normal background image (non 9patch). So the problem is about background 9patch image.
UPDATED 2
There is a lot of questions/answers about using 9patch in background in SO, but because the problem I faced was applying the background I started to looking in google for "background image problems". Of course none of the result in google throw me any useful answer. When Kai gave me and advice about the problem I easily found the problem. So I'm not going to close the question because it can help to someone to go through.
The problem is that your background is set with a 9patch image that doesn't define both the stretch area (left and top corners) and the drawable area (right and bottom corners).
The solution is either modify 9patch image to include the necessary information, or set padding to 0 (android:padding="0dip" in XML or setPadding(0) in code).

Android TextView top image not rendering properly on 2.3

When I run my android application in Android version >=4 I got this out put(I didn't tested in android version 3):
When run the same application in android version 2.3 I got a bit different output:
You can see in second screenshot the image for about button is not visible. But when I try run the same application several times on 2.3 some times I got about image visible.Here is my code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/actionbar_with_right_button" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:scrollbars="none" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/snooze_button"
android:gravity="center"
android:onClick="showRemainderSnoozeSettings"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/snooze" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/help_button"
android:gravity="center"
android:onClick="showFaq"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/help" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:drawablePadding="#dimen/settings_text_view_drawable_padding"
android:drawableTop="#drawable/about_button"
android:gravity="center"
android:onClick="showAbout"
android:padding="#dimen/settings_text_view_padding"
android:text="#string/about" />
</LinearLayout>
</ScrollView>
I didn't understand why this is happening.
Can anyone help me to solve this issue.
Edit :
One more important thing I forgot to mention when I changed android:drawableTop="#drawable/about_button" to android:drawableTop="#drawable/help_button" of about TextView. It worked perfectly. So it can be an issue of my about_button image. So I recreated the about image again and put in all drawable folder. Even after that also I didn't get any +ve result. This issue only in 2.3 or less.
Thanks
May this help you:
Seems like this is a bug with android, where sometimes the first image in the drawable folder doesn't get displayed.....
I had a similar bug - a particular drawable was not being displayed, no matter in what ImageView. So I Added a dummy image called aaaa.png to the drawable folder and problem was solved....

Buttons appear transparent when I set a background image. I want Solid buttons

When using a small gif to be used as a background tile for a layout, I have found that my buttons appear transparent which is NOT what I want and I have not set any transparency parameters either (unless the background gif is transparent?)
My XML is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
android:background="#drawable/backgroundrepeat"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:id="#+id/scrollview1"
android:layout_weight="2"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/textview"
android:scrollbars="vertical"
android:textColor="#android:color/black"
/>
</ScrollView>
<Button android:text="Connect To Phidget" android:id="#+id/connect_button" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:layout_weight="0"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#null"
></Button>
</LinearLayout>
And the drawable tile is:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/original10"
android:tileMode="repeat"
/>
Can anyone help? Thanks
As per the Android developer documentation, it is quite clearly stated that using GIF images is discouraged.
While they don't elaborate on the reason - I'm assuming due to its multi-layering nature. But I've played with the GIF images and encountered unwanted errors similar to yours.
So I'd suggest you to export your GIF image to a PNG and try with that. You can use any tool like Gimp or IrfanViewer.
Ok. Than remove the tag:
android:background="#null"
That makes it transparent in the way you describe it.
add this tag in button
android:background="#android:drawable/btn_default"

1x1 size Nine-patch image not showing up on Android emulator device

I'd like to use a 1x1 size Nine-patch image from Android drawable resources.
When I'm trying to display it with <ImageView> in my layout xml file, this one is never showing up on the Android emulator device. Here's the xml code below:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10px"
>
<RelativeLayout
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="#+id/text_label"
android:text="#string/text"
android:textSize="10pt"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="#+id/my_checkBox"
android:layout_alignBaseline="#id/text_label"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<ImageView android:paddingTop="10px"
android:paddingBottom="10px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:src="#android:drawable/divider_horizontal_bright" />
</LinearLayout>
I tried another one with the same size and I have the same problem it's still blank.
My research on Google was irrelevant. Hope you can find what am I doing wrong here.
Thanks in advance for your help.
Lorenth
What version of the SDK are you writing for?
Take a peek at the divider_horizontal_bright.png files in the different versions :)
It's 99% transparent in 8, but like 50% transparent light grey in 4.
Or, Perhaps you meant divider_horizontal_bright_opaque?
This works for me:
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#android:drawable/divider_horizontal_dark"
android:scaleType="fitXY"
/>

Categories

Resources