我正在尝试使用标题,图像和滚动文本正文进行线性布局。出于某种原因,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>
我也尝试将文本主体放在自己的线性布局中(见上文),但没有小鸟。
答案 0 :(得分:1)
试试这个:
<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>
现在应该没事了!
答案 1 :(得分:0)
变化
android:layout_below="@id/DescHeader"
到
android:layout_below="@id/DescImage"