在5.5英寸以下的小型设备(Nexus,A3等)上,部分隐藏的RecyclerView
引起了我的麻烦
在加载Feed并将其添加到适配器项后,CoordinatorLayout
的所有子项都向上移动。
您可以查看演示 here
这是视图的层次结构:
CoordinatorLayout
AppBarLayout
LiveCollapsingToolbarLayout
CardView
ConstraintLayout
SmoothRecyclerView
这里是主要布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/live_main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/home_header_height_reduced"
android:fitsSystemWindows="true">
<com.radiofrance.radio.francebleu.android.view.toolbar.LiveCollapsingToolbarLayout
android:id="@+id/live_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:contentScrim="@color/bleu_primary"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:importantForAccessibility="noHideDescendants"
app:layout_collapseMode="parallax">
<ImageView
android:id="@+id/live_weather_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_date"
style="@style/HomeDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/live_ephemeris"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintVertical_bias="0.6"
tools:text="@tools:sample/date/day_of_week" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_ephemeris"
style="@style/HomeEphemeride"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/live_weather"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/live_date"
app:layout_constraintVertical_bias="1.0"
tools:text="St Guy" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_weather"
style="@style/HomeTemperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/live_ephemeris"
app:layout_constraintVertical_bias="0.7"
tools:text="14°" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin">
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_toolbar_title"
style="@style/TextHomeToolbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="@color/white" />
</androidx.appcompat.widget.Toolbar>
</com.radiofrance.radio.francebleu.android.view.toolbar.LiveCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.cardview.widget.CardView
android:id="@+id/live_card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/home_live_card_horizontal_margin"
android:layout_marginEnd="@dimen/home_live_card_horizontal_margin"
app:behavior_overlapTop="48dp"
app:cardElevation="3.8dp"
app:cardPreventCornerOverlap="@bool/card_overlap"
app:cardUseCompatPadding="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/live_card_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAccessibility="yes">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/live_card_cover"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="h,16:9"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/translucent"
app:layout_constraintBottom_toBottomOf="@id/live_card_cover"
app:layout_constraintLeft_toLeftOf="@id/live_card_cover"
app:layout_constraintRight_toRightOf="@id/live_card_cover"
app:layout_constraintTop_toTopOf="@id/live_card_cover" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
style="@style/TextHomeLiveStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/horizontal_margin"
android:layout_marginTop="14dp"
android:text="@string/home_live_status"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_card_player_debug"
style="@style/TextHomeLiveStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="14dp"
android:layout_marginEnd="@dimen/horizontal_margin"
android:visibility="gone"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Player debug" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_card_title"
style="@style/TextHomeLiveTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/horizontal_margin"
android:ellipsize="end"
android:maxLines="3"
app:layout_constraintBottom_toBottomOf="@+id/live_card_cover"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/live_card_player"
tools:text="Live de France Bleu" />
<com.radiofrance.radio.francebleu.android.view.progress.ProgressCircleImageView
android:id="@+id/live_card_player"
android:layout_width="@dimen/home_play_button_size"
android:layout_height="@dimen/home_play_button_size"
android:layout_marginEnd="@dimen/horizontal_margin"
android:layout_marginBottom="@dimen/horizontal_margin"
android:clickable="true"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="@+id/live_card_cover"
app:layout_constraintRight_toRightOf="parent"
app:pciv_background="@drawable/bg_play_dark"
app:pciv_padding="12dp"
app:pciv_progressBackground="@drawable/bg_play_progress_dark"
app:pciv_progressColor="@color/bleu_primary"
app:pciv_src="@drawable/eavd_vd_play" />
<LinearLayout
android:id="@+id/live_card_cover_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="@dimen/horizontal_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/live_card_cover">
<TextView
style="@style/HomeLiveTxt"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:ellipsize="end"
android:lines="2"
android:text="@string/home_call_description" />
<com.radiofrance.radio.francebleu.android.fonts.FontTextView
android:id="@+id/live_card_call"
style="@style/TextRobotoBold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/home_call_action"
android:text="@string/home_call_action"
android:textAllCaps="true"
android:textColor="@color/bleu_accent" />
</LinearLayout>
<com.radiofrance.radio.francebleu.android.view.error.GenericErrorView
android:id="@+id/live_card_error"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/white"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<com.radiofrance.radio.francebleu.android.view.scroll.SmoothRecyclerView
android:id="@+id/live_feed_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_overlapTop="48dp"
android:accessibilityTraversalAfter="@id/live_card_layout"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<include layout="@layout/card_see_new_actualities" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
[更新]
看来问题出在live_feed_recyclerview
中的水平回收视图是ViewHolder