我刚刚创建了一个浮动操作按钮并将属性对齐父级底部和右侧,但它没有显示我不知道我做错了什么,这是我的 xml 代码...... …………………………………………………………………………………………………………………………………………………………
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_show_order"
android:layout_width="368dp"
android:layout_height="624dp"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp"
tools:context="abtech.waiteriano.com.waitrer.PaymentActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#f0ff4800"
android:minHeight="?attr/actionBarSize" />
<ListView
android:layout_width="fill_parent"
android:id="@+id/showOrderListID"
android:layout_height="wrap_content"
tools:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="8dp"
android:layout_alignParentStart="true"
android:layout_below="@id/toolbar"/>
<TextView
android:id="@+id/tvPayment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/showOrderListID"
android:text="Payment Type:" />
<Spinner
android:id="@+id/paymentSpinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="@drawable/spinner_bg"
android:stateListAnimator="@drawable/spinner_sla"
android:layout_below="@+id/showOrderListID"
android:layout_alignBottom="@+id/tvPayment"
android:layout_toEndOf="@+id/tvPayment" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:src="@drawable/pay" />
</RelativeLayout>
使用这种布局:
删除高度,宽度声明并使用match_parent
属性......并FrameLayout
用作根布局。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_show_order"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#f0ff4800"
android:minHeight="?attr/actionBarSize" />
<ListView
android:id="@+id/showOrderListID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@id/toolbar"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />
<TextView
android:id="@+id/tvPayment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/showOrderListID"
android:text="Payment Type:" />
<Spinner
android:id="@+id/paymentSpinner"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tvPayment"
android:layout_below="@+id/showOrderListID"
android:layout_toEndOf="@+id/tvPayment"
android:background="@drawable/bottom_border_help"
android:stateListAnimator="@drawable/bottom_border_help" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:src="@mipmap/ic_launcher" />
</FrameLayout>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句