0

I have a design like this : XMLFile1.xml

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/option_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

  <ScrollView
    android:name="question_paper_scrollView"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true">

    <FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/fragment_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
  </ScrollView>
</RelativeLayout>

XMLFile2.xml

<RelativeLayout 
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:app="http://schemas.android.com/apk/res-auto"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="fill_parent"
 android:layout_height="match_parent">
  <include layout=XMLFile1.xml>
  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:gravity="center|bottom"
    android:weightSum="4"/>
 </RelativeLayout>

I have set the android:fillViewport="true" in ScrollView according to this and also set the minimumHeight() of the FrameLayout as per this. FrameLayout holds the quiz questions and they need to be scrollable and the LinearLayout consists of set of buttons like next, previous and clear. I learnt from this LinearLayout can hide the ScrollView but I can see the ScrollBar. What is the correct way to achieve : Scrollable questions with given design? PS: I am constrained to use LinearLayout because I want set of buttons at the bottom of the screen and to use FrameLayout because I am loading the quiz questions dynamically from the database.

SOLUTION: COMBINATION OF BOTH THE ANSWERS. USE wrap_content in all the layouts and user layout_below attribute in linear layout

Paul Schimmer
  • 161
  • 3
  • 22

2 Answers2

1

you can call bringToFront() for ScrollView If it doesn't block the views. Or adjust android:height of views. you also set ScrollView to android:layout_below="@id/includeView"

Elias Fazel
  • 2,093
  • 16
  • 20
1

Try this, in both xml file take all layout and view's height wrap_content instead of fill_parent or match_parent.

Dinal Koyani
  • 455
  • 3
  • 6
  • LinearLayout is for the buttons that act something like bottom tabs. On click next I load a new question into the frame. When I make LinearLayout's height to wrap_content all the buttons go up.Also the scrollview works only till the buttons and does not go beyond to display the text below the buttons – Paul Schimmer Nov 13 '17 at 05:26
  • Which orientation do you give to the linear layout? – Dinal Koyani Nov 13 '17 at 05:39
  • Horizantal orientation. If I changed that to vertical then the buttons are stacked one above others. I used linear layout for bottom tabs buttons following this:https://stackoverflow.com/questions/18944692/android-tabs-in-bottom-of-screen – Paul Schimmer Nov 13 '17 at 05:45
  • In xmlfile2 give some fixed height of linear layout and give android:layout_alignParentBottom="true" and remove android:gravity="center|bottom" – Dinal Koyani Nov 13 '17 at 05:55
  • Sorry but by doing that all the buttons go top of the screen – Paul Schimmer Nov 13 '17 at 07:13