android-layout - 带有底部按钮的 ListActivity

标签 android-layout

您好,我创建了一个 listActivity,其中包含一些数据行,并且在屏幕底部(不是列表)我放了一个按钮。我的问题是如果我的列表已满,因此需要滚动以便看到其他行,按钮似乎是透明的并与列表的最后一个元素重叠。所以它看起来不太舒服。你对如何解决这个问题有什么建议吗?有什么方法可以让我的列表为底部按钮留出一些空间吗?我不想用页脚 View 来实现它。我将发布 xml 文件,以便您可以获得更清晰的图片。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

  <DragNDrop.DragNDropListView
      android:id="@+id/android:list"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_weight="1" >
  </DragNDrop.DragNDropListView>

  <Button
      android:id="@+id/btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:alpha="1"
      android:drawableLeft="@drawable/back"
      android:text="Return" />

</RelativeLayout>

最佳答案

试试这个

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

  <Button
      android:id="@+id/btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:alpha="1"
      android:drawableLeft="@drawable/back"
      android:text="Return" />

  <DragNDrop.DragNDropListView
      android:id="@+id/android:list"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_above="@id/btn" >
  </DragNDrop.DragNDropListView>

</RelativeLayout>

在RelativeLayout中,元素默认放置在左上角,List无需指定

关于android-layout - 带有底部按钮的 ListActivity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11735490/

相关文章:

android - 使用约束布局将图像放在另一个图像的左上角

android - 处理带有两个 fragment 的操作栏

java - 我的 TextView 的奇怪布局

Android,为框架布局配置点击监听器

android - getMeasuredHeight() 和宽度在 measure() 之后返回 0

Android:滚动到 View 底部

Android - 拖屏导航

RelativeLayout 中的 Android 定位 View

android - 自定义 ListView 项目图形布局 Android

android - marginTop 不适用于 ConstraintLayout 和 wrap_content