Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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_Xml_Android Layout_Scrollview - Fatal编程技术网

Android 滚动视图不保持大小

Android 滚动视图不保持大小,android,xml,android-layout,scrollview,Android,Xml,Android Layout,Scrollview,我正在尝试制作一个带有标题、图像和滚动文本体的线性布局。出于某种原因,ScrollView似乎总是占据尽可能多的空间,因为它经常重叠标题和图像。我尝试过为每个对象指定权重,但它不会改变任何东西 这是我的线性布局 <LinearLayout android:id="@+id/gamedescriptionlayout" android:layout_width="fill_parent" android:layout_height="fill_pare

我正在尝试制作一个带有标题、图像和滚动文本体的线性布局。出于某种原因,ScrollView似乎总是占据尽可能多的空间,因为它经常重叠标题和图像。我尝试过为每个对象指定权重,但它不会改变任何东西

这是我的线性布局

<LinearLayout android:id="@+id/gamedescriptionlayout"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"
          android:background="@drawable/backdrop9"
          android:visibility="visible"
          android:layout_marginBottom="20dp"
          android:layout_marginTop="20dp"
          android:layout_marginLeft="20dp"
          android:layout_marginRight="20dp"
          android:layout_gravity="center"> 

 <TextView android:id="@+id/DescHeader"
           android:layout_height="wrap_content"     
           android:layout_width="fill_parent"
           android:layout_marginBottom="10dp"
           android:layout_marginTop="10dp"
           android:layout_marginLeft="10dp"
           android:layout_marginRight="10dp"
           android:gravity="center_horizontal"
           android:textColor="#000000"
           android:text="Level 1" 
           android:textSize="25dp"
           android:layout_weight="1"/> 

 <ImageView android:id="@+id/DescImage"
            android:layout_height="wrap_content"     
            android:layout_width="fill_parent"
            android:layout_below="@id/DescHeader"
            android:gravity="center"
            android:src = "@drawable/wall"
            android:layout_weight="1"/>

 <ScrollView android:id="@+id/DescScroll"
             android:layout_height="wrap_content"     
             android:layout_width="fill_parent"
             android:layout_marginBottom="10dp"
             android:layout_marginTop="10dp"
             android:layout_marginLeft="10dp"
             android:layout_marginRight="10dp"
             android:layout_weight="1">

 <LinearLayout android:id="@+id/DescContainer"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content">   
 <TextView android:id="@+id/DescBody"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" 
               android:textColor="#000000"
               android:text="HelloWorld LALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALA"/>
</LinearLayout> 
 </ScrollView>

</LinearLayout> 

我也尝试过将文本主体放在它自己的线性布局中(见上文),但没有任何限制

试试这个:

<LinearLayout android:id="@+id/gamedescriptionlayout"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:orientation="vertical"
          android:background="@drawable/backdrop9"
          android:visibility="visible"
          android:layout_marginBottom="20dp"
          android:layout_marginTop="20dp"
          android:layout_marginLeft="20dp"
          android:layout_marginRight="20dp"
          android:layout_gravity="center"> 

 <TextView android:id="@+id/DescHeader"
           android:layout_height="wrap_content"     
           android:layout_width="fill_parent"
           android:layout_marginBottom="10dp"
           android:layout_marginTop="10dp"
           android:layout_marginLeft="10dp"
           android:layout_marginRight="10dp"
           android:gravity="center_horizontal"
           android:textColor="#000000"
           android:text="Level 1" 
           android:textSize="25dp"
           android:layout_weight="0"/> 

 <ImageView android:id="@+id/DescImage"
            android:layout_height="wrap_content"     
            android:layout_width="fill_parent"
            android:layout_below="@id/DescHeader"
            android:gravity="center"
            android:src = "@drawable/wall"
            android:layout_weight="0"/>

 <ScrollView android:id="@+id/DescScroll"
             android:layout_height="0dp"     
             android:layout_width="fill_parent"
             android:layout_marginBottom="10dp"
             android:layout_marginTop="10dp"
             android:layout_marginLeft="10dp"
             android:layout_marginRight="10dp"
             android:layout_weight="1">

 <LinearLayout android:id="@+id/DescContainer"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content">   
 <TextView android:id="@+id/DescBody"
               android:layout_width="fill_parent"
               android:layout_height="wrap_content" 
               android:textColor="#000000"
               android:text="HelloWorld LALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALALA"/>
</LinearLayout> 
 </ScrollView>

</LinearLayout> 

现在应该没事了

变化

android:layout_below="@id/DescHeader"

android:layout_below="@id/DescImage"