简体   繁体   中英

Floating Action Button wrong position in TableLayout

As you can see TableLayout changes width of Button , ProgressBar and EditText components, but does not do the same for my FloatingActionButton .

  1. Here is a photo that explains my problem

  2. The result i want to get

In xml:

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

     xmlns:app="http://schemas.android.com/apk/res-auto"  >

   <TableLayout
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"

       android:stretchColumns="*" >

       <TableRow
           android:id="@+id/tableRow1"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" >

           <android.support.design.widget.FloatingActionButton
               android:id="@+id/FloatingActionButton04"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"

               android:src="@drawable/ic_launcher"
               app:elevation="4dp"
               app1:fabSize="mini" />

           <android.support.design.widget.FloatingActionButton
               android:id="@+id/FloatingActionButton03"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_launcher"
               app:elevation="4dp" />

           <android.support.design.widget.FloatingActionButton
               android:id="@+id/FloatingActionButton02"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_launcher"
               app:elevation="4dp" />

           <android.support.design.widget.FloatingActionButton
               android:id="@+id/FloatingActionButton01"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_launcher"
               app:elevation="4dp" />

           <android.support.design.widget.FloatingActionButton
               android:id="@+id/myFAB"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:src="@drawable/ic_launcher"
               app:elevation="4dp" />

       </TableRow>

       <TableRow
           android:id="@+id/tableRow2"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" >

           <Button
               android:id="@+id/Button04"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Button" />

           <Button
               android:id="@+id/Button03"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Button" />

           <Button
               android:id="@+id/Button02"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Button" />

           <Button
               android:id="@+id/Button01"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Button" />

           <Button
               android:id="@+id/button1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Button" />

       </TableRow>

       <TableRow
           android:id="@+id/tableRow3"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" >

           <ProgressBar
               android:id="@+id/progressBar1"
               style="?android:attr/progressBarStyleHorizontal"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:progress="60" />

       </TableRow>

       <TableRow
           android:id="@+id/tableRow4"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content" >

           <EditText
               android:id="@+id/editText1"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:ems="10"
               android:text="Width OK" >

               <requestFocus />
           </EditText>

       </TableRow>
   </TableLayout>

</RelativeLayout>

About Floating Action Button

A floating action button is used for a promoted action. Only one floating action button is recommended per screen to represent the most common action. Hence don't use so many action buttons in one raw. Use normal buttons instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM