我有一个这样的布局:
<ScrollView
android:id="@+id/ScrollViewHome"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/contentOuter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" >
<Gallery
android:id="@+id/home_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dip" >
</Gallery>
</LinearLayout>
</ScrollView>它将在屏幕中央显示我的画廊。因为图像的高度不适合整个屏幕,所以在图库的上方和下方都有一个空白区域。没问题的。然后我想在图库下面添加2个TextView:
<ScrollView
android:id="@+id/ScrollViewHome"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffff"
android:fillViewport="true" >
<LinearLayout
android:id="@+id/contentOuter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" >
<Gallery
android:id="@+id/home_banner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dip" >
</Gallery>
<RelativeLayout
android:id="@+id/topHot"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/topHotText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="@string/home_segment_home1"
android:textColor="#8e8e8e"
android:textSize="30dp"
android:textStyle="bold" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="@string/watch_all"
android:textColor="#8e8e8e"
android:textSize="30dp"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</ScrollView>添加<RelativeLayout>后,Gallery上下的空白区域变得更大。并且2 TextView inside <RelativeLayout>未显示。屏幕上仍然只有Gallery。为什么会这样呢?我写错了什么吗?请帮我解决这个问题。
发布于 2012-07-13 12:28:48
将垂直方向应用于滚动视图中的线性布局。这可能是一个原因。
发布于 2012-07-13 12:38:01
将线性布局更改为垂直布局
<LinearLayout
android:id="@+id/contentOuter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal" android:orientation="vertical"> https://stackoverflow.com/questions/11464102
复制相似问题