Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TextView text is missing on Samsung devices

I have an app in the Play Store. Some of my users reported that they cannot see labels. Problem seems to happen only on Samsung devices with Android version 4.1 and earlier. I could not repeat the problem on emulator. Has anyone encountered with something like this before?

enter image description here

TextViews appear as black boxes. These are ordinary textviews.

<TextView
    android:id="@+id/text_box"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:background="@drawable/phone_list_row_border"
    android:gravity="center_vertical"
    android:maxLines="1"
    android:text="\tBla bla bla"
    android:textColor="@color/black"
    android:textSize="@dimen/list_row_text_size"/>

<TextView
    android:id="@+id/text_eksi"
    style="@style/animating_button_labels"
    android:layout_gravity="center"
    android:layout_marginTop="-10dp"
    android:gravity="center"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:text="@string/eksi_sozluk"
    android:textAppearance="?android:attr/textAppearanceLarge"/>

I found this question but that seems to solve the problem by coincidence. I am stuck as I cannot repeat the problem on any of my devices. I need some sort of hint to repeat the error or find the cause.

Thanks.

Edit: phone_list_row_border.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle"
       android:thickness="1dp">

    <stroke
        android:width="2dp"
        android:color="#44aa77"/>

    <corners android:radius="10dp"/>

    <padding
        android:bottom="5dp"
        android:left="10dp"
        android:right="10dp"
        android:top="5dp"/>
</shape>

Other one has a drawable in the style. Its xml is here:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:bottom="-2dp"
        android:left="-2dp"
        android:right="-2dp"
        android:top="1dp">
        <shape android:shape="rectangle">
            <stroke
                android:width="1dp"
                android:color="@color/black"/>
        </shape>
    </item>
</layer-list>
like image 380
b4da Avatar asked Jul 30 '15 05:07

b4da


2 Answers

Problem seems to happen only on Samsung devices with Android version 4.1 and earlier.

Yes, this is a know issue in some Samsung, LG and HTC devices. I have an app with a decent user base and I had myself experienced this issue.

I am stuck as I cannot repeat the problem on any of my devices.

As you have not mentioned which devices you have tested it on and couldn't reproduce, I have to assume that they aren't those specific devices having the problem.

This is very minor problem with the style, where some specific devices from some specific manufacturers running on some specific Android versions are known to exhibit.

I myself faced this problem on some Android devices from manufacturers like Samsung, LG and HTC running versions 4.1, 4.2 or 4.3. Till now, never saw this on Lollipop or Kitkat.

Solution

Enough of talking, now lets go for the solution.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle"
       android:thickness="1dp">

    <stroke
        android:width="2dp"
        android:color="#44aa77"/>

    <corners android:radius="10dp"/>

    <padding
        android:bottom="5dp"
        android:left="10dp"
        android:right="10dp"
        android:top="5dp"/>
</shape>

This is your xml for the shape, right? Everything is correct in it except the fact that you haven't provided any background for the shape.

If you do not provide any background it will take black as default.

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
           android:shape="rectangle"
           android:thickness="1dp">

        <stroke
            android:width="2dp"
            android:color="#44aa77"/>

        <corners android:radius="10dp"/>

        <padding
            android:bottom="5dp"
            android:left="10dp"
            android:right="10dp"
            android:top="5dp"/>

    <solid android:color="#ffffff" />
    </shape>

Adding a solid color to the shape should solve the problem in those specific devices.

Testing

I have such a device which is know to exhibit this weird problem, I tested on it and it seems to work absolutely fine. You should never have this problem on higher versions of Android and mostly never on stock Android.

Hope it helps you.

like image 117
Aritra Roy Avatar answered Oct 28 '22 06:10

Aritra Roy


There is an issue with some Android versions which do not interpret the @android:color/transparent properly. Which might be set as default color at some points.

Try to fix this by setting the color manually.

E.g. add this line to your shapes to change the solid color.

<solid android:color="#00ffffff" />
like image 42
foxy Avatar answered Oct 28 '22 05:10

foxy