繁体   English   中英

底部的 ScrollView RelativeLayout 元素不可见

[英]ScrollView RelativeLayout element at the bottom is not visible

我在ScrollView有一个RelativeLayout ,其中不同的元素在Fragment内膨胀。

我观察到的是, RelativeLayout底部的元素不可见。 scroll启用我向下滚动,但最底层的元素是绝对不会看到。

下面我也试过了,还是一样

1) 使用LinearLayout

2)在底部使用不同的元素。

布局文件内容如下:

<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>

我将您的布局复制到一个测试应用程序中,对我来说它看起来不错。 我假设您看不到的视图是 Submit... 按钮,对吗?

在此处输入图片说明

您是在实际手机上还是在模拟器上运行它?

也许尝试为该按钮添加一个底部边距(仅用于测试),以查看是否以某种方式使其可见。

我使用示例应用程序尝试了您的代码,并且能够看到底部元素。 附上滚动开始和结束的屏幕截图。 我相信底部元素是按钮。 你还有这个问题吗?

在此处输入图片说明

在此处输入图片说明

我通过将它添加到我的网格布局解决了我的问题

android:layout_marginBottom="50dp"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM