Ich habe eine schwebende Aktionsschaltfläche an einer minimierten Symbolleiste verankert. Wenn meine Aktivität beginnt, hat mein FAB eine normale Größe und ist unten rechts verankert.Ein FAB daran hindern, seine Größe zu ändern
Wenn verkleinern die Symbolleiste die FAB verschwindet.
Ich würde es vorziehen, die FAB zu halten und haben es nicht verschwinden, wenn die Symbolleiste zusammenbricht. Ich bin mir nicht sicher, wie ich das machen soll. Kann mir jemand dabei helfen?
Mein Layout:
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/main_collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
>
<ImageView
android:id="@+id/photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/main.toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<TextView
android:id="@+id/article_body"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="20sp"
android:lineSpacingMultiplier="@fraction/detail_body_line_spacing_multiplier" />
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/share_fab"
android:stateListAnimator="@anim/fab_state_list_anim"
android:background="@drawable/add_fab_background"
android:layout_marginRight="@dimen/fab_margin"
android:layout_width="56dp"
android:layout_height="56dp"
android:src="@drawable/ic_share"
android:elevation="@dimen/fab_elevation"
android:contentDescription="@string/action_share"
app:layout_anchor="@id/main.appbar"
app:layout_anchorGravity="bottom|right|end"/>
</android.support.design.widget.CoordinatorLayout>
versuchen, diese Änderung ** 'android in Ihre kleine Änderung machen: id = "@ + id/main.appbar"' ** to ** 'android: id =" @ + id/main_collapsing "' ** ** deines "FloatingActionButton" ** –