當我試圖將ImageView
錨定在AppbarLayout
中時,我遇到了一個奇怪的問題。當試圖將它錨定在協調器佈局中時ImageView是一半隱藏
在設計它看起來像這樣:
,當我運行的應用程序,它看起來像:
我的代碼:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:fitsSystemWindows="true"
android:focusableInTouchMode="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="true"
app:contentScrim="@color/transparent"
app:layout_scrollFlags="enterAlways">
<ImageView
android:id="@+id/banner_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
app:layout_collapseMode="parallax"
app:srcCompat="@color/blue"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:id="@+id/signup_screen_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView
android:id="@+id/screen_label"
android:text="@string/signup"
android:gravity="center"
android:textAllCaps="true"
android:padding="@dimen/screen_label_padding"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.mypackage.android.views.register.StepIndicatorView
android:id="@+id/step_indicator"
android:layout_below="@id/screen_label"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/steps_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/layout_bottom"
android:layout_below="@id/step_indicator"/>
<LinearLayout
android:id="@id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:padding="@dimen/bottom_layout_padding">
<Button
android:id="@+id/previous_button"
style="?borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/registration_steps_back"
android:textColor="@color/next_button_color"
android:textSize="@dimen/back_button_text_size"/>
<Button
android:id="@+id/next_button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/sel_wizard_next_button"
android:foreground="?attr/selectableItemBackground"
android:text="@string/next"
android:textColor="@color/white"
android:textSize="@dimen/next_button_text_size"/>
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.CardView
app:layout_anchor="@+id/appbar"
app:layout_anchorGravity="bottom|center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:src="@color/black"
android:layout_width="80dp"
android:layout_height="80dp"/>
</android.support.v7.widget.CardView>
</android.support.design.widget.CoordinatorLayout>
任何想法爲什麼發生這種情況?
我想問題是你在'CollapsingToolbarLayout'上設置了'android:clipChildren =「true」'。你爲什麼這麼做?如果不需要嘗試刪除它,它應該已經嘗試 – rom4ek
。它不是那個 – matrix