我的问题是我的 ListView 在absoulteLayout上完美工作,但底部的按钮没有显示!我放置了一个带有绝对布局的 ScrollView ,其中包含所有项目( TextView 、按钮等),并且在 ScrollView 之外放置了 ListView ,这也不起作用,只需滚动按钮,但 ListView 只是移动一点,怎么可以我放置了一个 ScrollView ,可以看到按钮上的按钮并使 ListView 起作用? 我的 XML:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- The main content view -->
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/Ab">
<ListView
android:layout_width="317dp"
android:layout_height="429dp"
android:id="@+id/listView"
android:layout_gravity="center"
android:layout_x="45dp"
android:layout_y="41dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Works Monica!!"
android:id="@+id/TV1"
android:layout_gravity="center_horizontal"
android:layout_x="120dp"
android:layout_y="22dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Play :D"
android:id="@+id/TESTME"
android:layout_gravity="center_horizontal|bottom"
android:layout_x="190dp"
android:layout_y="520dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Pause"
android:id="@+id/PAUSE"
android:layout_x="110dp"
android:layout_y="521dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="37dp"
android:text="Lista"
android:id="@+id/LISTA"
android:layout_x="274dp"
android:layout_y="520dp" />
<CheckBox
android:layout_width="84dp"
android:layout_height="wrap_content"
android:text="Lista?"
android:id="@+id/CHECARL"
android:layout_x="267dp"
android:layout_y="490dp"
android:checked="false" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="BorrarL"
android:id="@+id/BORRARL"
android:layout_x="20dp"
android:layout_y="520dp" />
</AbsoluteLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#E6E6E7" />
最佳答案
您正在使用绝对布局,这意味着,从文档来看:
A layout that lets you specify exact locations (x/y coordinates) of its children.
因此,如果您没有看到按钮,那是因为它们位于设备屏幕边界之外。他们的位置是绝对/固定,所以无论如何他们都会呆在那里。
我建议更改为不同的布局。我不知道您正在构建什么类型的应用程序,但绝对布局通常不是最佳选择。
关于java - 使用 ListView 滚动布局 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29157243/