我正在尝试使用cardview中的recyclerview进行活动。在cardview上方有一个图像,我希望它在我滚动回收视图时消失,但没有使浅蓝色框消失。我怎样才能做到这一点? 我尝试使用NestedScrollView但没有结果
这是我的布局代码
<?xml version="1.0" encoding="utf-8"?>
<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:transitionName="itemMainTransition"
tools:context=".activity.WeatherActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/meteoTrentinoBanner"
android:background="#42a4ce"
android:src="@drawable/logo_meteotn"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginStart="5dp"
app:cardCornerRadius="5dp"
app:cardElevation="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:background="@drawable/weather_border">
<ImageView
android:id="@+id/backDay"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_back"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewMinTemp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_vertical|center_horizontal"
android:textSize="19sp"
android:textStyle="bold"
android:textColor="#0000FF"/>
<TextView
android:id="@+id/textViewDay"
android:text="@string/oggi"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:textAlignment="center"
android:textSize="25sp"
android:textStyle="bold"
tools:ignore="NestedWeights" />
<TextView
android:id="@+id/textViewMaxTemp"
android:layout_width="40dp"
android:layout_height="match_parent"
android:textAlignment="center"
android:gravity="center_vertical|center_horizontal"
android:textSize="19sp"
android:textStyle="bold"
android:textColor="#FF0000"/>
</LinearLayout>
<ImageView
android:id="@+id/forwardDay"
android:layout_width="70dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_forward"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal"
android:background="@drawable/weather_border">
<ImageView
android:id="@+id/meteoInfo"
android:layout_width="40dp"
android:layout_height="match_parent"
android:src="@drawable/ic_info"/>
<TextView
android:id="@+id/textViewWeather"
android:textSize="23sp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollHorizontally="true"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewMeteo"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:2)
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".LeaveActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/colorPrimary" />
<android.support.design.widget.CoordinatorLayout
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.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:contentDescription="@string/app_name"
android:src="@mipmap/ic_launcher"
app:layout_collapseMode="parallax" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardElevation="5dp"
app:cardPreventCornerOverlap="true"
app:cardUseCompatPadding="true">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/resView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>