代码之家  ›  专栏  ›  技术社区  ›  androidXP

嵌套滚动视图不显示内部坐标布局

  •  0
  • androidXP  · 技术社区  · 6 年前

    我有 CoordinatorLayout 具有 NestedScrollView CollapsingToolbarLayout 是的。我把所有东西都放在折叠工具栏布局中,我想先在屏幕上显示,然后添加 嵌套滚动视图 显示更多内容,但是 嵌套滚动视图 在屏幕上不可见。

    这是我的XML布局

    <?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:fitsSystemWindows="true"
        android:clipToPadding="false"
        android:background="?android:attr/colorBackground"
        android:id="@+id/viewuserProfileMain"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">
    
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">
                <RelativeLayout
                    android:id="@+id/relativeParent"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <ImageView
                        android:id="@+id/upCoverPhoto"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="@color/redName"/>
    
    
                    <!--PUT TOOLBAR HERE-->
                    <RelativeLayout
                        android:id="@+id/upDetails"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:background="@drawable/diagonal_cut_layerlist"
                        android:elevation="12dp"
                        android:translationZ="12dp"
                        android:layout_marginLeft="15dp"
                        android:layout_marginRight="15dp"
                        android:layout_marginTop="115dp">
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginTop="115dp"
                            android:layout_marginRight="10dp"
                            android:gravity="end"
                            android:orientation="horizontal">
                            <Button
                                android:id="@+id/Button_FollowFriends"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                style="@style/AppButton"
                                android:text="Follow"
                                />
    
                        </LinearLayout>
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:orientation="vertical">
    
                            <de.hdodenhof.circleimageview.CircleImageView
                                android:id="@+id/profilePicture_Cut"
                                android:layout_width="80dp"
                                android:layout_height="80dp"
                                android:src="@drawable/baby"
                                app:civ_border_width="2dp"
                                app:civ_border_color="@color/primary"
                                android:layout_marginTop="85dp"
                                android:layout_marginLeft="15dp"/>
                            <TextView
                                android:id="@+id/upUserName"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:textColor="@color/secondary_text"
                                android:layout_marginTop="10dp"
                                android:textSize="28sp"
                                android:layout_marginLeft="10dp"
                                android:text="Susan Ledger"/>
    
                            <TextView
                                android:id="@+id/upUserCity"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:drawableLeft="@drawable/home"
                                android:drawablePadding="5dp"
                                android:layout_marginTop="5dp"
                                android:layout_marginLeft="10dp"
                                android:textSize="18sp"
                                android:textColor="@color/secondary_text"
                                android:text="Delhi,India"/>
    
                            <LinearLayout
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="15dp"
                                android:gravity="center"
                                android:orientation="horizontal"
                                android:weightSum="3">
                                <Button
                                    android:id="@+id/Button_AddFriend"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    style="@style/AppButton"
                                    android:text="Add Friend"
                                    android:layout_weight="1"/>
    
                                <Button
                                    android:id="@+id/Button_RejectRequest"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    style="@style/AppButton"
                                    android:text="Reject"
                                    android:layout_weight="1"/>
    
                                <Button
                                    android:id="@+id/Button_MessageFriend"
                                    android:layout_width="0dp"
                                    android:layout_height="wrap_content"
                                    style="@style/AppButton"
                                    android:text="Message"
                                    android:layout_weight="1"/>
    
    
    
                            </LinearLayout>
    
                        </LinearLayout>
    
    
    
                    </RelativeLayout>
                </RelativeLayout>
    
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
    
    
        <android.support.v4.widget.NestedScrollView
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/up_NestedScrollView"
            android:fillViewport="true"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
    
    
            <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:paddingLeft="5dp"
                android:paddingRight="5dp"
                >
    
                <!--To show tab on top of view pager-->
                <android.support.design.widget.TabLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:tabMode="scrollable"
                    app:tabTextColor="@color/place_autocomplete_prediction_primary_text_highlight"
                    app:tabSelectedTextColor="@color/primary_text"
                    app:tabIndicatorColor="@color/primary_light"
                    android:id="@+id/up_Viewpager_Tab">
                </android.support.design.widget.TabLayout>
                <android.support.v4.view.ViewPager
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_below="@id/userProfile_Viewpager_Tab"
                    android:id="@+id/up_Viewpager_ViewPager">
    
                </android.support.v4.view.ViewPager>
    
    
    
            </RelativeLayout>
    
        </android.support.v4.widget.NestedScrollView>
    </android.support.design.widget.CoordinatorLayout>
    
    2 回复  |  直到 6 年前
        1
  •  0
  •   Aaditya Brahmbhatt    6 年前

    给予 wrap_content 在你的高度 AppBarLayout

    <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    

    以及

       `android:fitsSystemWindows="false"
        app:contentScrim="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"`
    

    这些行到您的 CollapsingToolbarLayout

        2
  •  0
  •   Abdugani_T    6 年前

    尝试给予

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:fitsSystemWindows="true">
    

    因为 AppBar 不可能是 match_parent