Android应用程序RelativeLayout没有显示

时间:2012-04-06 18:18:43

标签: android-layout

所以即时尝试使用相对布局(对于屏幕底部的基本应用程序选项卡),当我将其放置在2个其他布局(LinearLayout和ScrollView)之后的LinearLayout中时,它没有显示。 ScrollView包含几个textViews并且可以很好地滚动它们之前的linearlayout也可以很好地工作,但是我试图放在屏幕底部的relativelayout不起作用。 以下是我想要做的一般代码:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:orientation="vertical"
    android:background="@drawable/common_bg"
    android:layout_height="fill_parent">

    <LinearLayout android:layout_width="fill_parent"
        android:layout_height="50dp">

        <TextView android:layout_height="50dp"
            android:text="Heading"
            android:gravity="center"
            android:textSize="17dp"
            android:textColor="@color/white"
            android:textStyle="bold"
            android:layout_width="fill_parent">
        </TextView>
    </LinearLayout>

    <ScrollView android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scrollbars="none"
        android:layout_gravity="top" 
        android:layout_marginBottom="60dp">

           <LinearLayout android:layout_width="fill_parent"
            android:orientation="vertical"
            android:paddingTop="15dp"
            android:layout_weight="1"
            android:paddingLeft="15dp"
            android:paddingRight="15dp"
            android:layout_height="fill_parent">

           <TextView android:layout_width="wrap_content"
                         android:textColor="@color/white"
                         android:textSize="18dp"
                         android:textStyle="bold"
                         android:text="@string/text"
                 android:layout_height="wrap_content">
           </TextView>


           </LinearLayout>

    </ScrollView>

    <RelativeLayout
        android:id="@+id/bottomMenu"
        android:layout_width="wrap_content"
        android:layout_height="60dp" />

</LinearLayout>

更新:我使用的相对布局是自定义的,我不能在这里实际显示它的代码,但它包含一个带有几个按钮的无线电组。

更新2:好的,所以我通过操纵3个布局上的layout_height =“wrap_content”解决了这个问题(第一个线性,一个握住滚动条,底部相对布局)以及操纵每个布局的layout_wieght它们直到我对它看起来的方式感到满意......看起来这似乎是最好的解决办法,但它确实有用,所以我不能抱怨太多哈哈...

1 个答案:

答案 0 :(得分:0)

相对布局本身不会以xml图形布局显示,或者当您运行应用程序时,它需要一个子元素来占用父布局,尝试将文本视图放在相对布局中,它将被显示,将它放置在具有滚动视图的线性布局的正下方,它将正常工作,我只是尝试使用您的代码并且它可以正常工作

相关问题