【发布时间】:2016-05-09 01:21:51
【问题描述】:
首先,我想说声抱歉,但我在设计 android 应用程序时遇到了问题:D 我希望该按钮位于列表视图下方。实际上按钮位于列表视图上方并隐藏下部区域。我该如何解决?
我的布局文件:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize"
android:background="@color/white"
tools:context="de.app.me.de.MyFragment">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ListView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/listview_ticket"
android:layout_gravity="center"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="3dp"
/>
</android.support.v4.widget.SwipeRefreshLayout>
<Button
android:layout_width="match_parent"
android:layout_height="60dp"
android:id="@+id/btn_reply"
android:text="Antworten"
android:layout_gravity="center_horizontal|bottom"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/orange"
android:textColor="@color/white"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"/>
</FrameLayout>
【问题讨论】:
-
您应该使用 LinearLayout 并将方向设置为垂直而不是 FrameLayout。原因:最后添加的视图位于堆栈顶部。由于按钮是最后添加的,因此我们将始终在列表视图的顶部。希望我足够清楚。
标签: android xml listview layout