我在NestedScrollView
中有recyclelerview和其他cardview这是完整的xml
<?xml version="1.0" encoding="utf-8"?><FrameLayout
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"
tools:ignore="MissingPrefix"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/home_content_padding">
<android.support.v7.widget.CardView
android:id="@+id/card_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/card_background"
app:cardUseCompatPadding="true"
app:cardElevation="@dimen/card_home_elevation"
app:cardCornerRadius="@dimen/card_home_corner_radius"
app:contentPadding="@dimen/card_home_content_padding">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:textSize="14sp"
android:text="@string/home_description"
fontPath="fonts/Font-Regular.ttf"/>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="@+id/home_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardUseCompatPadding="true" />
<android.support.v7.widget.CardView
android:id="@+id/card_more_apps"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?attr/card_background"
app:cardUseCompatPadding="true"
app:cardElevation="@dimen/card_home_elevation"
app:cardCornerRadius="@dimen/card_home_corner_radius">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/home_more_apps_header"
android:textSize="16sp"
android:textColor="?android:attr/textColorPrimary"
android:padding="@dimen/home_content_padding"
fontPath="fonts/Font-Bold.ttf"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/divider_list" />
<com.balysv.materialripple.MaterialRippleLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:mrl_rippleAlpha="0.15"
app:mrl_rippleColor="?attr/card_ripple"
app:mrl_rippleDelayClick="true"
app:mrl_rippleOverlay="true"
app:mrl_rippleDuration="500"
app:mrl_rippleDimension="4dp" >
<LinearLayout
android:id="@+id/more_apps"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:padding="@dimen/home_content_padding">
<ImageView
android:id="@+id/more_apps_icon"
android:layout_width="40dp"
android:layout_height="40dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/home_more_apps"
android:textSize="14sp"
android:layout_marginLeft="@dimen/home_content_padding"
android:layout_marginStart="@dimen/home_content_padding"
android:textColor="?android:attr/textColorSecondary"
fontPath="fonts/Font-Regular.ttf"/>
</LinearLayout>
</com.balysv.materialripple.MaterialRippleLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<View
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_shadow"
android:background="@drawable/toolbar_shadow" /></FrameLayout>
我面临的问题是当应用首次启动时,第一张卡片视图隐藏在recyclerview后面。观看此视频,了解确切问题{{3}}
我尝试将父LinearLayout更改为RelativeLayout,然后使用layout_below属性,但这不起作用。 知道可能是什么问题吗?此外,我是一个代码的初学者,所以如果有一些我错过的愚蠢的东西,请放轻松。 感谢
答案 0 :(得分:0)
终于找到了解决方案,唯一需要的是将recyclerview设置为不可聚焦,如RecyclerView.setFoucsable(false);
以下是原始答案Link