为什么在Android布局中 - 相对布局有些元素没有显示?

时间:2014-03-26 15:34:48

标签: android xml layout

对水平和垂直布局有点新意。 当使用包含进度条的相对布局,两个文本视图和一个页脚xml时,仅显示标题和进度条(仅限横向)。

这是我的XML布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/border_rounded">
    <include
        android:id="@+id/layHead"
        layout="@layout/infoheader"
        android:layout_height="wrap_content"
        android:layout_width="match_parent" />
    <LinearLayout
        android:minWidth="25px"
        android:orientation="horizontal"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="180dip">
        <ProgressBar
            android:id="@+id/pbConnect"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="fill_parent"
            android:layout_height="55dp"
            android:progress="50"
            android:progressDrawable="@drawable/progressbar"
            android:layout_marginLeft="3.0dp"
            android:layout_marginRight="3.0dp" />
        <TextView
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tvInfo"
            android:gravity="center" />
        <TextView
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/tvSubInfo"
            android:gravity="center" />
        <include
            android:id="@+id/layFoot"
            layout="@layout/infofooter"
            android:layout_height="wrap_content"
            android:layout_width="match_parent" />
    </LinearLayout>
</RelativeLayout>

我该如何解决这个问题?相对布局是否适合在景观活动中使用?

1 个答案:

答案 0 :(得分:0)

仅显示进度条,因为在进度条中,您使用fill_parent作为布局宽度,这就是为什么它采用整个父宽度。在线性布局中使用weigthSum或使用Relative Layout