0

First the title may look senseless but I don't know how I describe my problem well in the title.

I have a Relative layout which has 2 buttons (Past games and Upcoming Games) and 2 listviews. Whenever a button is pressed the associated listview is collapsed (height will be zero) if it is already expanded or the reverse will happen. ( i used this solution)

Problem: Everything is fine when I run it on a 5-inch screen phone. Please see the following picture:

[![][2]][2]

But if I run it on a 10-inch tablet it looks like this:

[![][3]][3]

The same will happen when it will run on less than 5-inch phone.

My questions

  • Do I need to make another layout for the tablet? like in the layout-large folder?

  • or I can use some event(s) in Jave file that dynamically set the buttons align parent bottom property when the listview is not collapsed.

  • or it can be fixed in my current XML

Below is the code for that part I am asking for help

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_marginTop="10dp"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/btnPastGames"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"
            android:background="@color/YellowColor"
            android:text="Past Games"
            android:textAllCaps="false"
            android:textSize="15sp" />

        <ListView
            android:id="@+id/lvPastGames"
            android:layout_width="match_parent"
            android:layout_height="255dp"
            android:layout_below="@+id/btnPastGames"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="17dp"
            android:layout_marginStart="17dp"
            android:layout_marginTop="5dp"
            android:divider="@null" />

        <Button
            android:id="@+id/btnUpcommigGames"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_below="@+id/lvPastGames"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"
            android:background="@color/YellowColor"
            android:text="Up Coming Games"
            android:textAllCaps="false"
            android:textSize="15sp" />

        <ListView
            android:id="@+id/lvUpcomingGames"
            android:layout_width="match_parent"
            android:layout_height="255dp"
            android:layout_below="@+id/btnUpcommigGames"
            android:layout_centerHorizontal="true"
            android:layout_marginLeft="17dp"
            android:layout_marginStart="17dp"
            android:divider="@null" />

    </RelativeLayout>

</LinearLayout>

If you guys can give me some advice on making the user interface that will run on all screen sizes and densities I will be very thankful

Thanks to anyone who will help me

Community
  • 1
  • 1
Hashoo
  • 47
  • 7
  • You want the *btnUpcommigGames* Button to be always at the bottom of the screen? – Rami Oct 12 '15 at 17:17
  • No, the button btnUpcommingGames should be below the btnPastGames when the lvPastGames is collapsed otherwise it should stay at bottom. – Hashoo Oct 12 '15 at 17:33

1 Answers1

0

You are trying to workaround functionality of ExpandableListView. Look at the following page:

http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/

Iliiaz Akhmedov
  • 867
  • 7
  • 17