我尝试按照以下方式制作我的布局:first pic
但相反,我得到了这个:second pic(不要忘记按钮的颜色不同)
第一张图片中的 FAB (浮动操作按钮)是默认的android FAB,但在第二张图片中我使用此github.com/Clans/FloatingActionButton来实现FAB
activity_mystackOverflowQuestion.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"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.coquenim.gradebook.Activities.SubjectActivity">
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:id="@+id/viewA"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:layout_height="60dp"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Stack"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="70dp"
android:paddingEnd="70dp"
android:paddingStart="@dimen/activity_horizontal_margin"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Overflow"
android:paddingLeft="50dp"
android:paddingRight="@dimen/activity_horizontal_margin"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="@drawable/divider"
android:dividerPadding="8dp"
android:orientation="horizontal"
android:showDividers="middle"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="00.00"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:id="@+id/subjectAveragee"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="00.00"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:id="@+id/subject_target_grade"
/>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_subject"/>
<com.github.clans.fab.FloatingActionMenu
android:id="@+id/fab_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
fab:menu_labels_style="@style/MenuLabelsStyle"
fab:menu_labels_showAnimation="@anim/jump_from_down"
fab:menu_labels_hideAnimation="@anim/jump_to_down"
fab:menu_animationDelayPerItem="0"
fab:menu_shadowColor="#444"
fab:menu_colorNormal="#FFB805"
fab:menu_colorPressed="#F2AB00"
fab:menu_colorRipple="#D99200"
app:layout_anchor="@id/viewA"
app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
content_myStackOverflowQuestion.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:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_subject"
tools:context="com.example.coquenim.gradebook.Activities.SubjectActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/currentSubjectName"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:padding="8dp"
android:textIsSelectable="false"
android:textSize="24sp"
android:textColor="@color/textColorBlack"
/>
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/expandableListView"
android:layout_below="@+id/currentSubjectName"
android:childDivider="#00000000"
/>
</RelativeLayout>
答案 0 :(得分:0)
定义布局中各种元素的高程,并保持浮动操作按钮(fab)的高程大于所有其他元素