2017-04-26 120 views
-1

我刚创建了一个浮动动作按钮,并将属性aliign父母的底部和右侧,但它没有显示我不知道我做错了什么,这是我的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> 
+0

的android:layout_width = “368dp” 机器人:layout_height = “624dp” 删除,并使用match_parent –

回答

0

使用这种布局:

删除高度,宽度声明和使用match_parent attribute..and使用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> 
+0

thnaks很多老兄它工作得很好,现在 – DevDev

+0

高兴它的工作... – rafsanahmad007

0
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/fbLiveAccount" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:layout_alignParentRight="true" 
    android:layout_marginBottom="@dimen/scale_16dp" 
    android:layout_marginEnd="@dimen/scale_16dp" 
    android:layout_marginRight="@dimen/scale_16dp" 
    android:clickable="true" 
    android:src="@drawable/ic_add_black_24dp" 
    app:backgroundTint="@color/color_f27f17" /> 
+0

删除的android:layout_width =” “368dp” android:layout_height =“624dp”并设置为matchparent –

+0

请提供一些解释来回答这个问题 –

+0

哪一行你无法理解代码? –

相关问题