[英]NestedScrollView not showing inside CoordinatorLayout
I have CoordinatorLayout
with NestedScrollView
and CollapsingToolbarLayout
. 我有带有NestedScrollView
和CollapsingToolbarLayout
CoordinatorLayout
。 I put everything inside CollapsingToolbarLayout which i want to show on screen first then add NestedScrollView
to show more content but NestedScrollView
is not visible on screen. 我将所有内容放到想要首先在屏幕上显示的CollapsingToolbarLayout中,然后添加NestedScrollView
以显示更多内容,但NestedScrollView
在屏幕上不可见。
Here is my XML Layout 这是我的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>
Give wrap_content
in height of your AppBarLayout
在您的AppBarLayout
高度中设置wrap_content
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
And 和
`android:fitsSystemWindows="false"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"`
these lines to your CollapsingToolbarLayout
这些行到您的CollapsingToolbarLayout
try give 尝试给
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:fitsSystemWindows="true">
Because AppBar
could not be match_parent
因为AppBar
不能为match_parent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.