Android 当定位点处于活动状态时,使cardView滚动
我有一个问题,我希望顶部的橙色cardView是这样的: 当用户嘲笑我时,我也必须让这张橙色卡片滚动 但我使用了带有锚的协调布局 当用户滚动一点时,我必须使其不可见,但我有以下几点: 我的问题是如何使这个橙色的cardview与其他布局元素保持并滚动 我的xml文件是:Android 当定位点处于活动状态时,使cardView滚动,android,android-studio,android-cardview,android-nestedscrollview,Android,Android Studio,Android Cardview,Android Nestedscrollview,我有一个问题,我希望顶部的橙色cardView是这样的: 当用户嘲笑我时,我也必须让这张橙色卡片滚动 但我使用了带有锚的协调布局 当用户滚动一点时,我必须使其不可见,但我有以下几点: 我的问题是如何使这个橙色的cardview与其他布局元素保持并滚动 我的xml文件是: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:elevation="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="@+id/profile_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_marginLeft="@dimen/app_margin"
android:layout_marginRight="@dimen/app_margin"
android:layout_marginBottom="@dimen/app_margin"
app:elevation="3dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:layout_marginTop="60dp"
android:layout_marginBottom="@dimen/app_margin"
android:text="Mark Davis"
android:layout_centerHorizontal="true"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="@id/username"
android:text="IT consuler"
android:layout_marginBottom="@dimen/app_margin"
android:id="@+id/textView" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView"
android:layout_marginTop="15dp"
android:layout_weight="1"
android:elevation="3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Personal Information"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.CardView>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_margin="@dimen/app_margin"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium"
android:text="Personal Inforamtion"
android:elevation="3dp"
android:textStyle="bold"
android:layout_margin="@dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="User Name"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/colorAccent"
android:layout_marginBottom="@dimen/app_margin"
android:layout_marginLeft="@dimen/app_margin"
android:textAppearance="@style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="User Name"
android:layout_marginLeft="32dp"
android:layout_marginRight="@dimen/app_margin"
android:layout_marginBottom="@dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/colorAccent"
android:layout_marginBottom="@dimen/app_margin"
android:layout_marginLeft="@dimen/app_margin"
android:textAppearance="@style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:layout_marginLeft="32dp"
android:layout_marginRight="@dimen/app_margin"
android:layout_marginBottom="@dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Display name"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/colorAccent"
android:layout_marginBottom="@dimen/app_margin"
android:layout_marginLeft="@dimen/app_margin"
android:textAppearance="@style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Display name"
android:layout_marginLeft="32dp"
android:layout_marginRight="@dimen/app_margin"
android:layout_marginBottom="@dimen/app_margin"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:textStyle="bold"
android:textSize="16sp"
android:textColor="@color/colorAccent"
android:layout_marginBottom="@dimen/app_margin"
android:layout_marginLeft="@dimen/app_margin"
android:textAppearance="@style/TextAppearance.AppCompat.Small"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:layout_marginLeft="32dp"
android:layout_marginRight="@dimen/app_margin"
android:layout_marginBottom="@dimen/app_margin"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.v7.widget.CardView
android:id="@+id/profile_pic"
android:layout_margin="@dimen/app_margin"
android:layout_width="100dp"
android:layout_height="100dp"
app:layout_anchor="@id/profile_card"
app:layout_anchorGravity="center|top"
app:cardCornerRadius="50dp"
app:cardBackgroundColor="@color/colorAccent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/ic_profile"/>
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/buttonLove"
android:layout_width ="wrap_content"
android:layout_height="wrap_content"
android:src = "@drawable/ic_edit"
app:borderWidth="0dp"
android:elevation="5dp"
app:pressedTranslationZ="12dp"
app:rippleColor="@color/button_white"
android:onClick="onClick"
android:background="@color/colorAccent"
android:layout_margin="@dimen/app_margin"
android:layout_gravity="bottom|end"
app:fabSize="normal"
/>
</android.support.design.widget.CoordinatorLayout>
如果我错了,请纠正我,当用户滚动时,您希望同时滚动带有橙色徽标的卡并隐藏徽标?不完全是这样,当用户向下滚动时,我只希望滚动橙色徽标,而不希望隐藏或锚损坏,我可以使用RelativeLayout而不是coordinateLayout,但是晶圆厂呢?