0

i am developing a layout, which contains below item

In top, Horizontally 3 text views under that one listview.

if i make listview as a visible the top 3 textview getting hided.

if i make top 3 textviews as visible the listview getting hided.

can anyone help me make both textviews and listview visible?

code :

<?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:orientation="horizontal">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_gravity="top"
        android:layout_weight=".1" >

        <TextView
            android:id="@+id/day_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="sunday"
            android:gravity="center"/>

    </LinearLayout>

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

        <TextView
            android:id="@+id/date_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="jun 01, 2017"
            android:gravity="center"/>

    </LinearLayout>

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

        <TextView
            android:id="@+id/holiday_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:text="New Yearr's day"
            android:gravity="center"/>

    </LinearLayout>

    <ListView
        android:id="@+id/list_holiday"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#999999"
        android:dividerHeight="1dp"
        android:background="@color/listbg"
        android:visibility="visible"
        android:layout_marginTop="50dp" />


</LinearLayout>
Happy
  • 1,031
  • 10
  • 26
  • Why do you give weight and height to your LinearLayouts at the same time. If you want to have them weight you should use 0dp for height – Thracian May 20 '17 at 07:45
  • There are no Spinners in xml file you shared but it's probably total height of TextViews and LinearLayouts exceeding the screen height. Check it and it will be fine. – Thracian May 20 '17 at 07:47

2 Answers2

2

Hopefully this will solve Your issue

<?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:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/day_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight=".1"
            android:gravity="center"
            android:text="sunday" />

         <TextView
            android:id="@+id/date_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight=".1"
            android:gravity="center"
            android:text="jun 01, 2017" />

        <TextView
            android:id="@+id/holiday_col"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_weight=".1"
            android:gravity="center"
            android:text="New Yearr's day" />

    </LinearLayout>

    <ListView
        android:id="@+id/list_holiday"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="50dp"
        android:background="@android:color/listbg"
        android:divider="#999999"
        android:dividerHeight="1dp"
        android:visibility="visible" />

</LinearLayout>
0

You can use PercentLayout to set height of the views by 100% without using LinearLayouts with weights. You can also check here to see how it's implemented.

Community
  • 1
  • 1
Thracian
  • 43,021
  • 16
  • 133
  • 222