【发布时间】:2018-11-04 16:00:48
【问题描述】:
我正在尝试在 cardview 中使用 recyclerview 进行活动。在cardview上方有一个图像,当我滚动recyclerview时我希望它消失但不让浅蓝色框消失。我怎样才能做到这一点? 我尝试使用 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>
【问题讨论】:
-
您的回收站视图是否应该滚动到蓝色框上?
-
不,蓝色框应该始终可见,图像应该在滚动回收视图时消失。卡片视图应转换为顶部,隐藏图像
-
现在的行为是什么?
-
目前图像和盒子都固定了,只有recyclerview滚动
标签: android xml layout android-recyclerview imageview