Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 包含长文本视图时缺少linearlayout背景_Android_Android Layout_Android Linearlayout_Textview - Fatal编程技术网

Android 包含长文本视图时缺少linearlayout背景

Android 包含长文本视图时缺少linearlayout背景,android,android-layout,android-linearlayout,textview,Android,Android Layout,Android Linearlayout,Textview,我有个问题。我有一个几乎没有垂直线性布局的视图,所有视图都有背景,其中一个视图有四个文本视图。这些文本视图中有三个是短的静态文本,但其中一个是我用编程方式填充的文本,而这个文本有时相当长。 当文本长度超过2300个字符时,父线性布局的背景将消失。我不知道为什么 我的视图定义: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/a

我有个问题。我有一个几乎没有垂直线性布局的视图,所有视图都有背景,其中一个视图有四个文本视图。这些文本视图中有三个是短的静态文本,但其中一个是我用编程方式填充的文本,而这个文本有时相当长。 当文本长度超过2300个字符时,父线性布局的背景将消失。我不知道为什么

我的视图定义:

<?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>

这里有些东西。。。
这里有些东西。。。
id为“description\u content”的Textview是以编程方式填充的长文本视图

和屏幕截图(很抱歉链接,但我无法添加图像):

编辑: 感谢@Haresh的回答,它给了我一些新的想法。我使用了一个大约2380个字符的文本,当我开始使用填充时,结果是当我以文本视图高度较短的方式更改文本时,背景就出现了

因此,在线性布局的某个“固定”高度之后,它似乎缺少背景

但我仍然不知道为什么会发生这种情况。

//试试这种方法,希望这能帮助你解决问题。。。
// 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>
这里有些东西。。。 这里有些东西。。。
不幸的是,这不是线性布局的问题。您的视图/布局对于android渲染器来说太大了。查看我应用程序中的日志(我有相同的问题):

较新的硬件或软件配置具有更高的限制。
我发现唯一的解决办法就是用witch的方法来画形状,有时候真的很复杂(你需要画一些矩形,线作为边框+圆角的不同方法)

尝试将第一条直线的高度设置为匹配\u家长仍然与匹配\u家长相同:/此处讨论了此行为的更好解释。感谢您的回答。它没有解决问题,但请给我一些想法。A已经更新了问题。
W/OpenGLRenderer﹕ Shape round rect too large to be rendered into a texture (436x6933, max=4096x4096)