Android Layout Listview在relativelayout下的高度调整

标签 android layout

我想添加一个 listview 或 tableview 占据屏幕的 2/3,然后在 listview 正下方的中心会有一个巨大的按钮。现在的问题是 ListView 占据了整个屏幕的高度。我无法调整图形布局的高度。我只想占用 5 个项目的高度大小。下面是屏幕上的按钮中心,

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:id="@+id/relativeLayout"
   android:padding="3dp" xmlns:android="http://schemas.android.com/apk/res/android">
 <ListView android:layout_height="wrap_content"
  android:id="@+id/listView1"
   android:layout_width="fill_parent" android:layout_alignParentLeft="true" 
   android:layout_alignParentTop="true"></ListView>

</RelativeLayout>

最佳答案

    <?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
       android:id="@+id/relativeLayout"
       android:padding="3dp" xmlns:android="http://schemas.android.com/apk/res/android">

<ListView android:layout_height="fill_parent"
      android:id="@+id/listView1"
      android:layout_above="@+id/button1"
      android:layout_width="fill_parent"></ListView>

<Button android:layout_height="wrap_content"
      android:id="@+id/button1"
      android:layout_alignParentBottom="true"
      android:layout_width="fill_parent"></Button >

    </RelativeLayout>

关于Android Layout Listview在relativelayout下的高度调整,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8692179/

相关文章:

html - 3 个盒子正确堆叠所需的 CSS float 帮助

html - 仅使用纯 html 和 css 在多个列上添加 html 内容?

android - 在 Android 上使用 QUdpSocket 发送数据

Android 手机作为 USB 键盘/HID-Gadget/

android - MediaPlayer类的stop方法

android - 在具有嵌套 fragment 的 View 寻呼机上方显示对话框

iOS:在宽 UIView 中居中 UIImageView

html - CSS 左 : -50% causing IE7 to ignore width

swift - UIStackView 不显示

Android:GPS 坐标可以在模拟器上工作,但不能在手机上工作