按钮下方的列表不显示 [英] Button below a list not showing

查看:215
本文介绍了按钮下方的列表不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我终于让我的列表中正确显示(的http://stackoverflow.com/questions/5662277/how-to-line-up-intger-output-in-custom-android-dialog).

I finally managed to get my list to display properly (http://stackoverflow.com/questions/5662277/how-to-line-up-intger-output-in-custom-android-dialog).

现在我想添加列表下方的按钮。什么情况是,当列表太大按钮不会显示。
这份名单是滚动的,但仅此而已。
此外,滚动条涵盖了一些数据。

Now I am trying to add a button below the list. What happens is that when the list is too big the button doesn't show. The list is scrollable but that's it. Also, the scrollbar covers some of the data.

这是主要的XML文件:

This is the main XML file:

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

    <LinearLayout android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent" android:layout_height="wrap_content" 
                 android:orientation="horizontal">
      <TextView     android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer4Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:layout_margin="2dp"/>
    </LinearLayout>
   <ListView android:id="@+id/lvwScores" android:layout_below="@id/lloPlayerNames"
       android:layout_width="fill_parent" android:layout_height="wrap_content"
       android:layout_centerHorizontal="true" />

    <Button android:id="@+id/btnOK  "
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
      android:layout_below="@id/lvwScores" android:layout_weight="1"
     android:text="OK" android:layout_centerHorizontal="true" />
</RelativeLayout>

这是一个用于行:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">
  <TextView android:id="@+id/tvwPlayer1Score" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView android:id="@+id/tvwPlayer2Score" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView android:id="@+id/tvwPlayer3Score" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView android:id="@+id/tvwPlayer4Score" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
</LinearLayout>

我试图改变主线性布局,但,使得事情变得更糟!该列表看起来像它一直在崩溃饮食,是超薄。

I tried changing the main to a linear layout but that made it even worse! The list looked like it had been on a crash-diet and was super-thin.

试过:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">

    <LinearLayout android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent" android:layout_height="wrap_content" 
                 android:orientation="horizontal">
      <TextView     android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer4Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:layout_marginRight="2dp"/>
    </LinearLayout>
    <Button android:id="@+id/btnOK"
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:text="OK" android:layout_centerHorizontal="true" 
     layout_alignParentBottom="true"/>
   <ListView android:id="@+id/lvwScores" android:layout_above="@id/btnOK" android:layout_below="@id/lloPlayerNames" 
       android:layout_width="fill_parent" android:layout_height="wrap_content"
       android:layout_centerHorizontal="true" android:layout_weight="1"/>

</RelativeLayout>

和我所得到的是:

and what I get is:

当我尝试:

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
                 android:orientation="vertical">>

    <LinearLayout android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
                 android:layout_width="fill_parent" android:layout_height="wrap_content" 
                 android:orientation="horizontal">
      <TextView     android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
      <TextView     android:id="@+id/tvwPlayer4Name" android:layout_weight="1" android:gravity="right"
                    android:layout_width="fill_parent" android:layout_height="wrap_content"
                    android:layout_marginRight="2dp"/>
    </LinearLayout>
   <ListView android:id="@+id/lvwScores" 
       android:layout_width="fill_parent" android:layout_height="wrap_content"
       android:layout_centerHorizontal="true" android:layout_weight="1"/>
    <Button android:id="@+id/btnOK"
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:text="OK" android:layout_centerHorizontal="true" 
     layout_alignParentBottom="true"/>

</LinearLayout>

我得到:

推荐答案

您应该把按钮列表前,然后用列表元素的layout_above属性来定位它上面的按钮。另外补充 layout_alignParentBottom =真正的您的按钮。

You should put the button before the list and then use the layout_above property on the list element to position it above the button. Also add layout_alignParentBottom="true" to your button.

像这样:

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

<LinearLayout 
  android:id="@+id/lloPlayerNames" xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="wrap_content" 
  android:orientation="horizontal">
  <TextView
    android:id="@+id/tvwPlayer1Name" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView
    android:id="@+id/tvwPlayer2Name" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView     
    android:id="@+id/tvwPlayer3Name" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>
  <TextView     
    android:id="@+id/tvwPlayer4Name" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_margin="2dp"/>
</LinearLayout>

<Button android:id="@+id/btnOK"
  android:layout_height="wrap_content" android:layout_width="wrap_content" 
  android:layout_below="@id/lvwScores" android:layout_weight="1"
  android:text="OK" android:layout_centerHorizontal="true" 

  android:layout_alignParentBottom="true" 

   />

<ListView 
   android:id="@+id/lvwScores" 
   android:layout_below="@id/lloPlayerNames"

   android:layout_above="@id/btnOK"

   android:layout_width="fill_parent" android:layout_height="wrap_content"
   android:layout_centerHorizontal="true" />

这篇关于按钮下方的列表不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆