android - 底部的 ScrollView RelativeLayout 元素不可见

标签 android android-layout

我在 ScrollView 中有一个 RelativeLayout,在 Fragment 中包含不同的元素。

我观察到 RelativeLayout 底部的元素不可见。 滚动 在我向下滚动时启用,但最底部的元素永远不可见。

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

1) 使用线性布局

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>

最佳答案

我将您的布局复制到测试应用中,我觉得它不错。我假设您看不到的 View 是“提交...”按钮,对吗?

enter image description here

你是在真手机上运行还是在模拟器上运行?

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

关于android - 底部的 ScrollView RelativeLayout 元素不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39938909/

相关文章:

javascript - 在 android 中从 webview 中拉出单个变量?

android - 如果动态加载,SVG 不会在 android 和 safari 上播放动画

android - 在 Android 上只捕获 ENOSPC

java - 在重新启动手机之前,我无法在图库中看到下载的图像

Android 自定义布局抛出 android.view.InflateException

android - 在 Android 中制作像按钮一样的玻璃

android - 如何在 Android 应用程序中为所有页面使用字体

android - "MissingRegistered"使用 com.google.android.material.* UI 组件时的 Lint 警告

android - FragmentPagerAdapter 和 PagerAdapter 的区别

android - 有没有办法为AccountKit Android 定制登录UI?