Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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中CoordinatorLayout中另一个视图的下方_Android_Xml_Android Layout - Fatal编程技术网

将视图放置在android中CoordinatorLayout中另一个视图的下方

将视图放置在android中CoordinatorLayout中另一个视图的下方,android,xml,android-layout,Android,Xml,Android Layout,我想在我的xml文件中使用android.support.design.widget.CoordinatorLayout,android.support.design.widget.AppBarLayout,android.support.design.widget.collayout。将一个视图放置在另一个视图下方的可能性是什么 例如:将滚动视图置于图像视图下方的坐标布局 我的xml代码: <RelativeLayout xmlns:android="http://schemas.and

我想在我的xml文件中使用
android.support.design.widget.CoordinatorLayout
android.support.design.widget.AppBarLayout
android.support.design.widget.collayout
。将一个视图放置在另一个视图下方的可能性是什么

例如:将
滚动视图
置于
图像视图
下方的
坐标布局

我的xml代码:

<RelativeLayout 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_color"
    tools:context="com.tellfa.smsbox.activities.postShow_Page">

    <android.support.design.widget.CoordinatorLayout
        android:id="@+id/post_show_coordinator"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/post_show_collapsing_toolbar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                >

                <ImageView
                    android:id="@+id/post_picture_image"
                    android:layout_width="fill_parent"
                    android:layout_height="200dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/cover_menu_bg2"
                    android:visibility="visible"
                    app:layout_collapseMode="parallax" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/post_show_app_bar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
                    app:layout_collapseMode="pin">

                    <ImageView
                        android:id="@+id/post_show_fav_image"
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_gravity="right"
                        android:layout_marginRight="10dp"
                        android:alpha="0.7"
                        android:src="@drawable/favorite_post_un" />

                    <ImageView
                        android:id="@+id/post_show_share_image"
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_gravity="right"
                        android:layout_marginRight="10dp"
                        android:alpha="0.7"
                        android:src="@drawable/abc_ic_menu_share_mtrl_alpha" />

                    <ImageView
                        android:id="@+id/post_show_report_image"
                        android:layout_width="25dp"
                        android:layout_height="25dp"
                        android:layout_gravity="right"
                        android:layout_marginRight="10dp"
                        android:alpha="0.7"
                        android:padding="2dp"
                        android:src="@drawable/post_report" />

                </android.support.v7.widget.Toolbar>

                <RelativeLayout
                    android:id="@+id/post_show_space"
                    android:layout_width="fill_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:layout_below="@+id/post_picture_image"
                    android:visibility="gone" />

                <ScrollView
                    android:id="@+id/post_text_layout"
                    style="@style/scrollbar_shape_style"
                    android:layout_width="fill_parent"
                    android:layout_height="140dp"
                    android:layout_gravity="bottom"
                    app:layout_collapseMode="parallax">

                    <RelativeLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/category_text">

                        <com.tellfa.smsbox.components.tellfa_TextView_en
                            android:id="@+id/post_text_text"
                            android:layout_width="fill_parent"
                            android:layout_height="fill_parent"
                            android:layout_marginBottom="2dp"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:text="@string/connect_info"
                            android:textColor="@color/top_user_bg"
                            android:textSize="18sp" />

                    </RelativeLayout>

                </ScrollView>

            </android.support.design.widget.CollapsingToolbarLayout>

        </android.support.design.widget.AppBarLayout>


    </android.support.design.widget.CoordinatorLayout>

</RelativeLayout>


如何在下面的
ImageView
中设置
ScrollView
?TNX我假设您正在尝试将视图放置在
折叠工具栏布局
中。
折叠工具栏布局
扩展了
框架布局
,因此定位视图的唯一可能性是利用视图边距和重力。在您的情况下,您可以将
ImageView
定位为:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginTop="140dp" <-height of the ScrollView
/>

如何将一个视图定位到另一个视图的右侧?
<ImageView
    android:layout_width="match_parent"
    android:layout_height="100dp"
    app:layout_anchor="@+id/post_text_layout" <-view to anchor the imageview
    app:layout_anchorGravity="bottom" <- specifies edge of the anchor that should be used
    android:layout_gravity="bottom" <- how to position this view relatively to the anchoring position
/>