线性布局不可见

时间:2012-10-08 10:36:28

标签: android layout

在下面的代码中,极端底部的线性布局不可见。我尝试了几种方法,但无法使其可见。请看一下

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

    <include
        android:id="@+id/id_nav_bar"
        layout="@layout/app_nav_layout" />

    <ListView
        android:id="@+id/id_home_screen_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="@android:color/transparent" />

    <RelativeLayout
        android:id="@+id/id_linear_layout_system_capacity"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="105dip"
        android:background="@drawable/home_storage_bg"
        android:orientation="vertical" >

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginTop="40dip"
            android:gravity="center_horizontal"
            android:text="Dummy"
            android:textStyle="bold" />

        <LinearLayout
            android:id="@+id/id_linear_layout_seekbar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@drawable/home_seekbar_bg" />
    </RelativeLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/home_bottom_bg"/ >
    </LinearLayout>

3 个答案:

答案 0 :(得分:0)

你已经把

android:layout_width="wrap_content" android:layout_height="wrap_content"

as wrap_content,你的布局中没有内容,所以它可能不可见

答案 1 :(得分:0)

通过编辑如下代码解决了问题: -

<TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="17dip"
        android:gravity="center_horizontal"
        android:text="Dummy"
        android:textStyle="bold" />

答案 2 :(得分:-1)

据我了解,此隐形布局应始终显示在屏幕底部,那么您最好使用RelativeLayout LinearLayout 更改此布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/GlobalBG"
android:orientation="vertical" >

转到<RelativeLayout>并将此android:layout_alignParentBottom="true"设置为您的隐藏布局

编辑: 这对我有用

<?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="@color/red" >

<RelativeLayout
    android:id="@+id/id_linear_layout_system_capacity"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="105dip"
    android:background="@color/row_base_background_end"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginTop="20dip"
        android:gravity="center_horizontal"
        android:text="Dummy"
        android:textStyle="bold" />

    <LinearLayout
        android:id="@+id/id_linear_layout_seekbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:background="@color/row_base_background_start" />
</RelativeLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:background="@color/gray" >
</LinearLayout>

</RelativeLayout>
相关问题