Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.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 与协调器布局锚搏斗_Android_Layout_Android Coordinatorlayout - Fatal编程技术网

Android 与协调器布局锚搏斗

Android 与协调器布局锚搏斗,android,layout,android-coordinatorlayout,Android,Layout,Android Coordinatorlayout,我已经检查了关于堆栈溢出的每个问题,以便在两个布局的交叉处放置一个视图(最终问题:),但在使用建议的答案时,我看到了奇怪的行为 我的circularView总是放在cardView的左上角,我不知道为什么会发生这种情况。请在下面查找xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"

我已经检查了关于堆栈溢出的每个问题,以便在两个布局的交叉处放置一个视图(最终问题:),但在使用建议的答案时,我看到了奇怪的行为

我的circularView总是放在cardView的左上角,我不知道为什么会发生这种情况。请在下面查找xml:

<LinearLayout 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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context="com.phandaarpit.androidrecyclertutorial.MainActivity">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="250dp"
        app:cardUseCompatPadding="true"
        app:cardCornerRadius="5dp">

        <android.support.design.widget.CoordinatorLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <TextView
                    android:id="@+id/im_pic"
                    android:layout_width="match_parent"
                    android:layout_height="150dp"
                    android:background="?attr/colorControlHighlight"
                    />
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">
                    <TextView
                        android:id="@+id/profile_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Hello World!" />
                    <TextView
                        android:id="@+id/profile_sub_title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Hello World!" />
                </LinearLayout>
            </LinearLayout>

            <android.support.design.widget.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:elevation="2dp"
                app:layout_anchor="@id/im_pic"
                app:layout_anchorGravity="bottom|left"/>
        </android.support.design.widget.CoordinatorLayout>
    </android.support.v7.widget.CardView>

</LinearLayout>


那些
layou锚定*
属性在
cardwiew
本身中不起作用。他们只在
视图
上工作,这些视图是
协调器布局
的直接子视图。将
CircularImageView
移动到
CardView
标记的外部。@MikeM。我可以在cardview内部使用Coordinator或Layout,然后使用锚定标签吗?哦,我知道你现在想做什么了。道歉。我以为你在尝试锚定到
CardView
。您可以将
坐标布局
放在
卡片视图
中,但可能需要重新安排整体布局。锚定
视图
也应该是
CoordinatorLayout
的子视图。也尝试过@Mike M,但似乎不起作用。此外,我将锚定的视图和我正在锚定的视图是否需要是CoordinatorLayout的直接子视图?