Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 当尝试将ImageView锚定在Coordinatorlayout中时,它是半隐藏的_Android_Android Imageview_Android Coordinatorlayout - Fatal编程技术网

Android 当尝试将ImageView锚定在Coordinatorlayout中时,它是半隐藏的

Android 当尝试将ImageView锚定在Coordinatorlayout中时,它是半隐藏的,android,android-imageview,android-coordinatorlayout,Android,Android Imageview,Android Coordinatorlayout,当我尝试在AppbarLayout中锚定ImageView时,会遇到一个奇怪的问题 在设计器中,它如下所示: 当我运行应用程序时,它看起来像: 我的代码: <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ap

当我尝试在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>
知道为什么会发生这种情况吗?

设置CardView立面,将其放置在AppBarLayout前面。以下XML应该足够了:

   app:cardElevation="4dp"
4dp应该可以工作,但可能需要更高一点

我希望这对您有用。

设置CardView立面,将其放置在AppBarLayout前面。以下XML应该足够了:

   app:cardElevation="4dp"
4dp应该可以工作,但可能需要更高一点


我希望这对您有用。

我想问题在于您在CollasingToolbarLayout上设置了android:clipChildren=true。你为什么这么做?如果不需要,尝试删除它,它应该已经尝试过了。我想问题不在于你在折叠工具栏布局上设置了android:clipChildren=true。你为什么这么做?如果不需要,尝试删除它,它应该已经尝试过了。这不是说,是的,标高实际上在6dp下工作,但当其API 19或更低时会发生什么?@matrix支持库应该处理它。你知道它在API 19及以下版本上不起作用吗?@matrix如果这是公认的答案,别忘了奖励奖金。就这样吧。我无法在接下来的16小时内奖励它。不worry@Cheticamp我们怎么能把它完全隐藏起来呢?我有一个类似的问题,但我想在崩溃时隐藏它。是的,标高实际上在6dp下工作,但当其API 19或更低时会发生什么?@matrix支持库应该处理它。你知道它在API 19及以下版本上不起作用吗?@matrix如果这是公认的答案,别忘了奖励奖金。就这样吧。我无法在接下来的16小时内奖励它。不worry@Cheticamp我们怎么能把它完全隐藏起来呢?我也有类似的问题,但我想在崩溃时隐藏它。