首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >安卓布局不能正确显示与RelativeLayout下面的画廊?

问安卓布局不能正确显示与RelativeLayout下面的画廊?
EN

Stack Overflow用户
提问于 2012-07-13 12:25:23
回答 2查看 749关注 0票数 0

我有一个这样的布局:

代码语言:javascript
复制
<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:

代码语言:javascript
复制
<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。为什么会这样呢?我写错了什么吗?请帮我解决这个问题。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-13 12:28:48

将垂直方向应用于滚动视图中的线性布局。这可能是一个原因。

票数 1
EN

Stack Overflow用户

发布于 2012-07-13 12:38:01

将线性布局更改为垂直布局

代码语言:javascript
复制
 <LinearLayout
    android:id="@+id/contentOuter"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical|center_horizontal" android:orientation="vertical">  
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11464102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档