简体   繁体   中英

Linear Layout not visible

In the following piece of code the Linear Layout at the extreme bottom is not visible.I tried several methods but couldn't make it visible.Please take a look

 <?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>

you have put

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

as wrap_content and there is no content inside your layout so it is not visible maybe

Fixed the problem by editing the code as below:-

<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" />

As I understand this invisible layout should be always visible in the bottom of the screen, then you should better use RelativeLayout insted of LinearLayout Change this layout

<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" >

TO <RelativeLayout> and set this android:layout_alignParentBottom="true" to your invisible layout

Edited: this works for me

<?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM