我試圖實現在屏幕的右下角浮動按鈕,但底部利潤率不因某種原因失效:/我試圖改變邊距尺寸只在底部,但它沒有工作。浮動操作按鈕底邊距不起作用
佈局文件:
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer" />
</android.support.v4.widget.DrawerLayout>
app_bar_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="de.js_labs.gaminggroups.MainActivity"
android:id="@+id/appBarMainRl">
<include
layout="@layout/some_content" // Changed by LayoutInflater in Java ...
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
some_content.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"
app:useCompatPadding="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="50dp"
android:id="@+id/contentMyGroupsRl"
tools:context=".MainActivity">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_action_addgroup"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
app:fabSize="normal"
android:layout_margin="@dimen/fab_margin"
android:layout_alignParentBottom="true" />
</RelativeLayout>
截圖:https://i.stack.imgur.com/COpgF.png
謝謝: )我kown這個工作,但有沒有可能把浮動按鈕,在內容佈局文件?或者我應該在更改內容佈局時將其隱藏起來? @ Janik174當您更改佈局 – janik174
,你可以使用fab.hide()和fab.show()方法來改變動畫的知名度。 –