在我的应用程序中,我想在滚动视图中使用一些视图,例如ImageView
,TextView
,RecyclerView
等等...
我写下面的代码,但没有告诉我RecyclerView
!
我的代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/miniFullSearch_toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/size50"
android:background="@color/colorPrimary">
<ImageView
android:id="@+id/miniFullSearch_toolbarBack"
android:layout_width="@dimen/size30"
android:layout_height="@dimen/size30"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/padding10"
android:alpha="0.8"
android:padding="@dimen/padding5"
android:src="@drawable/back_arrow_image" />
<EditText
android:id="@+id/miniFullSearch_toolbarText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding5"
android:layout_toRightOf="@+id/miniFullSearch_toolbarBack"
android:alpha="0.8"
android:background="@android:color/transparent"
android:hint="@string/search"
android:textColor="@color/white"
android:textColorHint="@color/lightGray"
android:textSize="@dimen/font14" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/fullSearchMini_celebritiesLay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/miniFullSearch_toolbar">
<RelativeLayout
android:id="@+id/fullSearchMini_celebritiesHeaderLay"
android:layout_width="match_parent"
android:layout_height="@dimen/size50">
<TextView
android:id="@+id/fullSearchMini_celebritiesHeaderTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_margin="@dimen/padding10"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:text="@string/celebrities"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font16" />
<RelativeLayout
android:id="@+id/fullSearchMini_celebritiesHeaderLoadMore"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_margin="@dimen/padding10"
android:gravity="center_vertical">
<ImageView
android:id="@+id/fullSearchMini_celebritiesHeaderLoadMoreImage"
android:layout_width="@dimen/size20"
android:layout_height="@dimen/size20"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_next"
android:tint="@color/darkBlueGrey" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="@dimen/padding5"
android:layout_toLeftOf="@+id/fullSearchMini_celebritiesHeaderLoadMoreImage"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:text="@string/loadMore"
android:textColor="@color/darkBlueGrey"
android:textSize="@dimen/font14" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/fullSearchMini_celebritiesRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/fullSearchMini_celebritiesHeaderLoadMore" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
为什么不告诉我recyclerView?
答案 0 :(得分:0)
你这样做:
<NestedScrollView>
<RelativeLayout>
//All other views
<RecyclerView>
</RelativeLayout>
</NestedScrollView>
确保nestedScrollView中只有一个子布局。
第二我建议你这样做
ViewCompat.setNestedScrollingEnabled(recylerView,false);
希望这有帮助。