0

I have below layout

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<!-- The main content view -->
<FrameLayout
    android:id="@+id/content_frame"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/searchScreenBG">

        <RelativeLayout
            android:id="@+id/title_bar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_marginBottom="@dimen/_7sdp">

            <ImageButton
                android:id="@+id/ib_hamburger"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginEnd="@dimen/_16sdp"
                android:layout_marginRight="@dimen/_16sdp"
                android:layout_marginTop="@dimen/_15sdp"
                android:background="@android:color/transparent"
                android:contentDescription="@null"
                app:srcCompat="@drawable/ham_burger" />

            <com.rod.com.rod.ui.views.CTextView
                android:id="@+id/textView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/ib_hamburger"
                android:layout_centerHorizontal="true"
                android:text="@string/basic_details"
                android:textColor="@color/colorGreen" />

            <ImageButton
                android:id="@+id/ib_back"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true"
                android:layout_alignTop="@+id/ib_hamburger"
                android:layout_marginLeft="@dimen/_16sdp"
                android:layout_marginStart="@dimen/_16sdp"
                android:background="@android:color/transparent"
                android:contentDescription="@null"
                app:srcCompat="@drawable/left_arrow" />
        </RelativeLayout>

        <RelativeLayout
            android:id="@+id/reg_no_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/_5sdp"
            android:layout_below="@+id/title_bar"
            android:background="@color/colorWhite">

            <TextView
                android:id="@+id/tv_reg_no"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="19dp"
                android:textColor="@color/colorLightGrey" />
        </RelativeLayout>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_below="@+id/reg_no_layout"
            >
            <LinearLayout android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:orientation="vertical"
                android:layout_marginRight="@dimen/_10sdp"
                android:layout_marginLeft="@dimen/_10sdp"
                android:layout_weight="1">

                <RelativeLayout
                    android:id="@+id/basic_details"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginTop="@dimen/_10sdp"
                    android:background="@drawable/list_item_bg"
                    android:paddingBottom="@dimen/_10sdp">

                    <TextView
                        android:id="@+id/tv_district_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginLeft="50dp"
                        android:layout_marginStart="50dp"
                        android:layout_marginTop="11dp"
                        android:text="@string/district"
                        android:textColor="@color/colorBlack"
                        android:textSize="@dimen/_13sdp" />

                    <TextView
                        android:id="@+id/tv_district"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_district_label"
                        android:layout_alignStart="@+id/tv_district_label"
                        android:layout_below="@+id/tv_district_label"
                        android:text="TextView"
                        android:textColor="@color/colorLightGrey" />

                    <TextView
                        android:id="@+id/tv_tehsil_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_above="@+id/tv_district"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentRight="true"
                        android:layout_marginEnd="75dp"
                        android:layout_marginRight="75dp"
                        android:text="@string/tehsil"
                        android:textColor="@color/colorBlack" />

                    <TextView
                        android:id="@+id/tv_tehsil"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/tv_district"
                        android:layout_alignLeft="@+id/tv_tehsil_label"
                        android:layout_alignStart="@+id/tv_tehsil_label"
                        android:text="TextView"
                        android:textColor="@color/colorLightGrey" />

                    <TextView
                        android:id="@+id/tv_date_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_district"
                        android:layout_alignStart="@+id/tv_district"
                        android:layout_below="@+id/tv_district"
                        android:layout_marginTop="13dp"
                        android:text="@string/date"
                        android:textColor="@color/colorBlack" />

                    <TextView
                        android:id="@+id/tv_date"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_date_label"
                        android:layout_alignStart="@+id/tv_date_label"
                        android:layout_below="@+id/tv_date_label"
                        android:text="TextView"
                        android:textColor="@color/colorLightGrey" />

                    <TextView
                        android:id="@+id/tv_jild_no_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignBottom="@+id/tv_date_label"
                        android:layout_alignLeft="@+id/tv_tehsil"
                        android:layout_alignStart="@+id/tv_tehsil"
                        android:text="@string/jild_no"
                        android:textColor="@color/colorBlack" />

                    <TextView
                        android:id="@+id/tv_jild_no"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_jild_no_label"
                        android:layout_alignStart="@+id/tv_jild_no_label"
                        android:layout_below="@+id/tv_jild_no_label"
                        android:text="TextView"
                        android:textColor="@color/colorLightGrey" />

                    <TextView
                        android:id="@+id/tv_party_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_date"
                        android:layout_alignStart="@+id/tv_date"
                        android:layout_below="@+id/tv_date"
                        android:layout_marginTop="13dp"
                        android:text="@string/party"
                        android:textColor="@color/colorBlack" />

                    <TextView
                        android:id="@+id/tv_party"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignLeft="@+id/tv_party_label"
                        android:layout_alignStart="@+id/tv_party_label"
                        android:layout_below="@+id/tv_party_label"
                        android:text="TextView"
                        android:textColor="@color/colorLightGrey" />

                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dip"
                    android:layout_weight="1"
                    android:layout_below="@+id/basic_details"
                    android:layout_marginTop="13dp"
                    android:background="@drawable/list_item_bg">

                    <TextView
                        android:id="@+id/tv_member_details_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginLeft="@dimen/_40sdp"
                        android:layout_marginStart="@dimen/_40sdp"
                        android:layout_marginTop="14dp"
                        android:text="@string/member_details"
                        android:textColor="@color/colorBlack"
                        android:textSize="@dimen/_16sdp" />

                    <ListView
                        android:id="@+id/lv_members"
                        android:layout_width="match_parent"
                        android:layout_height="fill_parent"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_below="@+id/tv_member_details_label"
                        android:layout_marginLeft="@dimen/_40sdp"
                        android:layout_marginRight="@dimen/_40sdp"
                        android:layout_marginStart="@dimen/_40sdp"
                        android:layout_marginTop="16dp"
                        android:divider="@color/colorLightGrey"
                        android:dividerHeight="@dimen/_1sdp" />
                </RelativeLayout>
            </LinearLayout>

        </ScrollView>

    </RelativeLayout>

</FrameLayout>

I want to make the relative layout below basic_layout cover the whole of the rest screen. How can I achieve that. After searching I had found that I should put a linear layout inside my scroll view, and then relative layouts should added. But that's of no help. I want hierachy something like below:

----RelativeLayout
-------TitleBar
-------TextView
-------ScrollView (rest of screen)
----------RelativeLayout (upper portion of scroll view)
------------TextViews
----------RelativeLayout (rest of scrol view)
-------------TextView
-------------ListView

Any help please?

Naila
  • 270
  • 1
  • 4
  • 26
  • Why did you make everything a child of frame layout? – Aryan Raj Dec 15 '17 at 10:08
  • what type of layout you want to acheive exactly can you share a screen shot maybe ? – Umair Dec 15 '17 at 10:19
  • @AryanRaj coz i have to integrate a drawer as well – Naila Dec 15 '17 at 11:46
  • @Umair please check my edited question – Naila Dec 15 '17 at 11:52
  • @Naila ok now couple of questions. Why are you using drawer layout as parent layout and secondly you want to scroll listview and textviews in upper portion as well ? – Umair Dec 15 '17 at 11:56
  • @Umair I am adding it from some other activity (base activity). And I want to scroll the whole view inside scroll view tag, as well as list – Naila Dec 15 '17 at 12:02
  • @Naila ok now your problem is that the listview only shows one item or it's not matched parent right ? – Umair Dec 15 '17 at 12:04
  • @Umair it shows more than one items and that's decided on runtime. But even when I am getting more than one items size occupied by list view is only of one item's size. It's scrollable though ( that's fine). – Naila Dec 15 '17 at 12:06
  • ok I have posted the answer now your list will show 7-8 items and will be bigger and for the rest of the layout you need to use cardviews intead if you want to get the exact layout as in the screenshot. – Umair Dec 15 '17 at 12:09
  • @Naila and let me know if there is still some problem. – Umair Dec 15 '17 at 12:13
  • thanks @Umair.. I'll get back in a while :-) – Naila Dec 15 '17 at 12:22
  • In that case make the relative layout and the linear layout a child of relative layout which in turn will be the child of scrollview, since scrollview can have only one direct child. – Aryan Raj Dec 15 '17 at 12:23
  • @Naila glad I could be of any help. Please accept and upvote my answer if it helped you. thanks and happy coding :) – Umair Dec 15 '17 at 12:32
  • @Umair done :-) thanks – Naila Dec 15 '17 at 12:40

1 Answers1

1

Actually the problem is that you are using 2 layouts in your scrollview so the listview won't take the scroll of itself and it will limit the list height as well. To go around this you need to pass fix value to your listview then it will show completely within that specified height. And the rest of the layout if you want to get exactly as you have shown in the picture you need to use cardview instead.

  <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dip"
                    android:layout_weight="1"
                    android:layout_below="@+id/basic_details"
                    android:layout_marginTop="13dp"
                    android:layout_marginBottom="10dp"
                    android:background="@drawable/list_item_bg">

                    <TextView
                        android:id="@+id/tv_member_details_label"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginLeft="@dimen/_40sdp"
                        android:layout_marginStart="@dimen/_40sdp"
                        android:layout_marginTop="14dp"
                        android:text="@string/member_details"
                        android:textColor="@color/colorBlack"
                        android:textSize="16dp" />

                    <ListView
                        android:id="@+id/lv_members"
                        android:layout_width="match_parent"
                        android:layout_height="500dp"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentStart="true"
                        android:layout_below="@+id/tv_member_details_label"
                        android:layout_marginLeft="@dimen/_40sdp"
                        android:layout_marginRight="@dimen/_40sdp"
                        android:layout_marginStart="@dimen/_40sdp"
                        android:layout_marginTop="16dp"
                        android:divider="@color/colorLightGrey"
                        android:dividerHeight="@dimen/_1sdp" />
                </RelativeLayout>
Umair
  • 6,366
  • 15
  • 42
  • 50