Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/234.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 在滚动视图中时,线性布局的背景会消失,具体取决于线性布局的高度_Android_Android Fragments_Scrollview_Android Linearlayout - Fatal编程技术网

Android 在滚动视图中时,线性布局的背景会消失,具体取决于线性布局的高度

Android 在滚动视图中时,线性布局的背景会消失,具体取决于线性布局的高度,android,android-fragments,scrollview,android-linearlayout,Android,Android Fragments,Scrollview,Android Linearlayout,已解决 通过在不同的平板电脑上调试我的应用程序,“解决”了这个问题。我使用的第一款平板电脑是三星Tab 2 10.1。现在我使用的是三星Note10.1,它工作正常。我很乐意从任何遇到同样问题的人那里得到一些反馈,以便更多地了解它 发布 这是我在这个论坛上的第一篇帖子。 我正在为android开发一个应用程序,我面临一个具有挑战性的问题。我还没有找到任何与这个问题相关的帖子,因为我不知道如何解决它,所以我决定在这里解释一下。 假设这是我送给你的圣诞礼物;) 好的,这是我要做的。基本上,我用这个x

已解决 通过在不同的平板电脑上调试我的应用程序,“解决”了这个问题。我使用的第一款平板电脑是三星Tab 2 10.1。现在我使用的是三星Note10.1,它工作正常。我很乐意从任何遇到同样问题的人那里得到一些反馈,以便更多地了解它

发布 这是我在这个论坛上的第一篇帖子。 我正在为android开发一个应用程序,我面临一个具有挑战性的问题。我还没有找到任何与这个问题相关的帖子,因为我不知道如何解决它,所以我决定在这里解释一下。 假设这是我送给你的圣诞礼物;)

好的,这是我要做的。基本上,我用这个xml文件膨胀了一个片段:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >
    <ScrollView
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" >
        <LinearLayout
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           android:orientation="vertical" >
            <LinearLayout style="@style/LayoutDetailsStep" >
                <TextView
                   style="@style/textkey"
                   android:text="Name:" />
                <TextView
                   android:id="@+id/name"
                   style="@style/editkey" />
            </LinearLayout>
            <LinearLayout style="@style/LayoutDetailsStep" >
                <TextView
                   style="@style/textkey"
                   android:text="Description:" />
                <TextView
                   android:id="@+id/description"
                   style="@style/editkey" />
            </LinearLayout>
            <LinearLayout style="@style/LayoutDetailsStep" >
                <TextView
                   style="@style/textkey"
                   android:text="SOP:" />
                <WebView
                   android:id="@+id/sop"
                   style="@style/editkey" />
            </LinearLayout>
            <LinearLayout style="@style/LayoutDetailsStep" >
                <TextView
                   style="@style/textkey"
                   android:text="Notes:" />
                <TextView
                   android:id="@+id/notes"
                   style="@style/editkey" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

基本上,我的片段由一个ScrollView组成,它由4个线性布局组成,每个线性布局包含一个TextView和一个TextView/WebView。我将样式布局细节步骤应用于每个线性布局,即:

 <style name="LayoutDetailsStep"  >
     <item name="android:layout_width">fill_parent</item>
     <item name="android:layout_height">wrap_content</item>
     <item name="android:orientation">horizontal</item>
     <item name="android:background">@drawable/round_border</item>
     <item name="android:layout_marginLeft">20dp</item>
     <item name="android:layout_marginRight">20dp</item>
     <item name="android:layout_marginTop">5dp</item>
     <item name="android:layout_marginBottom">5dp</item>
 </style>
 <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
        <corners android:radius="20dp"/>
        <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp" />
        <solid android:color="#ffffffff" />
        <stroke android:width="3dp" android:color="#000000"/>
    </shape>

填补家长的空缺
包装内容
水平的
@可拉深/圆边
20dp
20dp
5dp
5dp
该样式包含一个背景*圆形边框*,即:

 <style name="LayoutDetailsStep"  >
     <item name="android:layout_width">fill_parent</item>
     <item name="android:layout_height">wrap_content</item>
     <item name="android:orientation">horizontal</item>
     <item name="android:background">@drawable/round_border</item>
     <item name="android:layout_marginLeft">20dp</item>
     <item name="android:layout_marginRight">20dp</item>
     <item name="android:layout_marginTop">5dp</item>
     <item name="android:layout_marginBottom">5dp</item>
 </style>
 <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
        <corners android:radius="20dp"/>
        <padding android:left="10dp" android:right="10dp" android:top="10dp" android:bottom="10dp" />
        <solid android:color="#ffffffff" />
        <stroke android:width="3dp" android:color="#000000"/>
    </shape>

当一切顺利的时候,我有一堆漂亮的4条直线布局和漂亮的圆形边框。只要线性布局中的项目较小,一切都很好。看起来是这样的:

当项目大于片段本身的大小时,就会出现问题当WebView/TextView(两者都有问题)的高度大于片段的高度时,背景消失。看起来是这样的:

实际上,文本视图非常小,并且这个问题不会发生在它们身上。但我可以显示相当大的网络视图,这会导致背景消失,这意味着网络视图的线性布局周围没有圆形边框。 我坚持认为它不是特定于WebView的,如果TextView足够大,我也会遇到同样的问题。

如果有人知道发生了什么。。。我很乐意阅读你的建议:D


Gordak

显然它是在4.0.4中修复的。

当你发布问题时,请使用标签android,因为大家都知道这是android问题。当你使用安卓标签时,你的问题将被突出显示,因为每个人都喜欢安卓,你会很快得到答案谢谢。显然,它还固定了文本代码的颜色;)