3

I have a problem. I have a view with few vertical linearlayout and all of them has backgrounds, in one of them there a four textviews. Three of those textviews has short static text, but one I am filling with text programmatically and this text sometimes is quite long. When the text is longer then ~2300 characters the background of parent linearlayout disappear. And I have no idea why?

My view definition:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/activity_background"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/rounded_white"
        android:orientation="vertical"
        android:padding="16dp"
        android:paddingBottom="30dp"
        android:shadowColor="@color/black"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5" >

        Some stuff here...
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/rounded_white"
        android:orientation="vertical"
        android:padding="16dp"
        android:paddingBottom="30dp"
        android:shadowColor="@color/black"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5" >

        Some stuff here...
    </LinearLayout>

    <LinearLayout
        android:id="@+id/section_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:background="@drawable/rounded_white"
        android:orientation="vertical"
        android:padding="16dp"
        android:paddingBottom="30dp"
        android:shadowColor="@color/black"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="5" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="6dp"
            android:gravity="left|center_vertical"
            android:textColor="@color/dark_gray"
            style="@style/TextLarge"
            android:text="@string/description_header" />

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/gray"
            style="@style/TextSmall"
            android:text="@string/from_wiki_monit" />

        <TextView
            android:id="@+id/description_content"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:lineSpacingMultiplier="1.2"
            android:textColor="@color/dark_gray"
            style="@style/TextSmall" />

        <TextView
            android:id="@+id/description_source_url"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textColor="@color/url_color"
            android:linksClickable="true"
            style="@style/TextSmall" />
    </LinearLayout>
</LinearLayout>

</ScrollView>

Textview with id "description_content" is the long one filled programmatically.

And screenshots (sorry for links but I can't add images):

enter image description here

enter image description here

Edit: Thanks to @Haresh answer, it give me some new thoughts. I took a text with ~2380 characters and when I started to play with padding it turns out that when I change it in the way that the textview height was shorter, then the background was present.

So it looks like after some 'fixed' height of LinearLayout it is missing background.

But still I don't have any clue why it is happening.

Arek_24
  • 97
  • 2
  • 10

2 Answers2

0
// Try this way,hope this will help you to solve your problem...

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true"
    android:scrollbars="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/activity_background"
        android:orientation="vertical"
        android:padding="10dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="30dp"
            android:background="@drawable/rounded_white"
            android:orientation="vertical"
            android:padding="10dp"
            android:shadowColor="@color/black"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="5" >

            Some stuff here...
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@drawable/rounded_white"
            android:orientation="vertical"
            android:padding="10dp"
            android:shadowColor="@color/black"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="5" >

            Some stuff here...
        </LinearLayout>

        <LinearLayout
            android:id="@+id/section_description"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:background="@drawable/rounded_white"
            android:orientation="vertical"
            android:padding="10dp"
            android:shadowColor="@color/black"
            android:shadowDx="0"
            android:shadowDy="0"
            android:shadowRadius="5" >

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:textColor="@color/dark_gray"
                style="@style/TextLarge"
                android:text="@string/description_header" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@color/gray"
                style="@style/TextSmall"
                android:layout_marginBottom="5dp"
                android:text="@string/from_wiki_monit" />

            <TextView
                android:id="@+id/description_content"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:lineSpacingMultiplier="1.2"
                android:textColor="@color/dark_gray"
                style="@style/TextSmall" />

            <TextView
                android:id="@+id/description_source_url"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColor="@color/url_color"
                android:layout_marginBottom="5dp"
                android:linksClickable="true"
                style="@style/TextSmall" />
        </LinearLayout>
    </LinearLayout>

</ScrollView>
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • Thanks for answer it didn't solve the problem, but give me some thoughts. A have updated the question. – Arek_24 May 27 '14 at 14:00
0

Unfortunately, it is not problem of LinearLayout. Your View/Layout is just too big for android renderer. See log from my app (I have same problem):

W/OpenGLRenderer﹕ Shape round rect too large to be rendered into a texture (436x6933, max=4096x4096)

Newer hardware or software configurations have higher limit. Only solution I have found is to draw shapes in onDraw() method of View, witch is sometimes really complicated (you need to draw few rectangles, lines as borders + different methods for rounded corners).

user1557434
  • 501
  • 5
  • 6