dacscan3669
dacscan3669

Reputation: 761

ScrollView RelativeLayout element at the bottom is not visible

I have a RelativeLayout within ScrollView with different elements inflated inside a Fragment.

What I have observed is the element at the bottom of the RelativeLayout is not visible. The scroll is enabled as I scroll down but the bottom-most element is never visible.

I have tried below as well,still the same

1) Using LinearLayout

2) Using a different element at the bottom.

The layout file content is as below:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/LinearLayout1"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  android:padding="10dp" >

  <GridView
    android:id="@+id/gridView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:numColumns="5"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"/>

  <View
    android:id="@+id/center_divider1"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/gridView1"
    android:background="@android:color/darker_gray" />

  <Spinner
    android:id="@+id/spinnerCountry"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="8dp"
    android:minWidth="250dp"
    android:layout_below="@+id/center_divider1"
    android:entries="@array/category" />

  <Spinner
    android:id="@+id/spinnerCity"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/spinnerCountry"
    android:layout_below="@+id/spinnerCountry"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"
    android:minWidth="250dp"
    android:entries="@array/cars_vehicles" />

  <View
    android:id="@+id/center_divider2"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/spinnerCity"
    android:background="@android:color/darker_gray" />

  <RadioGroup
    android:id="@+id/condition"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="horizontal"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="8dp"
    android:layout_below="@+id/center_divider2">

    <RadioButton
        android:id="@+id/radioUsed"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Used"
        android:checked="true" />

    <RadioButton
        android:id="@+id/radioNew"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New" />

  </RadioGroup>

  <View
    android:id="@+id/center_divider3"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/condition"
    android:background="@android:color/darker_gray" />

  <android.support.design.widget.TextInputLayout
    android:id="@+id/item_list_price"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="8dp"
    android:layout_below="@+id/center_divider3">

    <EditText
        android:id="@+id/price"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="price" />
  </android.support.design.widget.TextInputLayout>

  <android.support.design.widget.TextInputLayout
    android:id="@+id/item_list_year"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"
    android:layout_below="@+id/item_list_price">
    <EditText
        android:id="@+id/year"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="year of purchase" />
  </android.support.design.widget.TextInputLayout>

  <android.support.design.widget.TextInputLayout
    android:id="@+id/item_list_kms"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="4dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"
    android:layout_below="@+id/item_list_year" >
    <EditText
        android:id="@+id/kms"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="kms" />
  </android.support.design.widget.TextInputLayout>

  <android.support.design.widget.TextInputLayout
    android:id="@+id/item_list_mileage"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"
    android:layout_below="@+id/item_list_kms" >
    <EditText
        android:id="@+id/mileage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="mileage" />
  </android.support.design.widget.TextInputLayout>

  <RadioGroup
      android:id="@+id/airCondition"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:gravity="center"
      android:orientation="horizontal"
      android:layout_marginBottom="8dp"
      android:layout_marginStart="2dp"
      android:layout_marginEnd="2dp"
      android:layout_marginTop="8dp"
      android:layout_below="@+id/item_list_mileage" >

      <RadioButton
          android:id="@+id/Yes"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Yes"
          android:checked="true" />

      <RadioButton
          android:id="@+id/No"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="No" />
  </RadioGroup>

  <android.support.design.widget.TextInputLayout
    android:id="@+id/item_list_description"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="2dp"
    android:layout_marginEnd="2dp"
    android:layout_marginTop="4dp"
    android:layout_below="@+id/airCondition" >
    <EditText
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="description"
        android:inputType="textMultiLine"
        android:lines="3"
        android:minLines="3"
        android:gravity="top|left"
        android:maxLines="5" />
    </android.support.design.widget.TextInputLayout>

  <Button
    android:id="@+id/btnSelectPhoto"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:layout_marginTop="20dp"
    android:layout_below="@+id/item_list_description"
    android:text="Submit.." />

  </RelativeLayout>
</ScrollView>

Upvotes: 1

Views: 296

Answers (3)

student programmer
student programmer

Reputation: 1

I solved my problem by adding this to my grid layout

android:layout_marginBottom="50dp"

Upvotes: 0

Santoshastagi
Santoshastagi

Reputation: 186

I tried your code with a sample app and was able to see the bottom element. Attached screenshots of the start and end of the scroll. I believe the bottom element is the button. Are you still having the issue?

enter image description here

enter image description here

Upvotes: 0

AndroidDev
AndroidDev

Reputation: 21237

I copied your layout into a test app and it looks good to me. I assume that the view you cannot see is the Submit... button, right?

enter image description here

Are you running this on an actual phone or on an emulator?

Maybe try adding a bottom margin to that button (just for testing) to see if somehow that will make it visible.

Upvotes: 1

Related Questions