Reputation: 103
I have a problem with a RecyclerView: it does not scroll, here's my layout:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardElevation="1dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/square3"
android:src="@drawable/square"/>
<LinearLayout
android:layout_width="60dp"
android:layout_height="wrap_content"
android:id="@+id/lin"
android:orientation="vertical">
<TextView
android:id="@+id/day"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/nameeOfMonthTable"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recicloEvent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginRight="26dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/lin"
android:layout_alignBottom="@+id/square3"
android:layout_alignTop="@+id/square3"
android:layout_marginBottom="25dp"
android:paddingLeft="1dp"/>
<View
android:id="@+id/separatorDateRvCale2"
android:layout_width="1dp"
android:layout_alignTop="@+id/square3"
android:layout_height="200dp"
android:layout_alignBottom="@+id/square3"
android:layout_alignLeft="@+id/recicloEvent"
/>
<View
android:id="@+id/separatorDateRvCale"
android:layout_width="1dp"
android:layout_alignTop="@+id/square3"
android:layout_height="200dp"
android:layout_alignBottom="@+id/square3"
android:layout_alignLeft="@+id/recicloEvent"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
this is the adapter of another RecyclerView that scrolls correctly: the upper RecyclerView has inside another RecyclerView (the one that does not scroll correctly) The problem affects only the inner table (that is the one up). How can I solve this? Here's a screen: , the problem affects the RecyclerView that is cut at the bottom
Upvotes: 1
Views: 104
Reputation: 1558
just put this code in your xml
file
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/square3"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/square" />
<LinearLayout
android:id="@+id/lin"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/day"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/nameeOfMonthTable"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recicloEvent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/square3"
android:layout_alignTop="@+id/square3"
android:layout_marginTop="20dp"
android:layout_toRightOf="@id/lin"
android:background="@color/colorWhite" />
<View
android:id="@+id/separatorDateRvCale2"
android:layout_width="1dp"
android:layout_height="200dp"
android:layout_alignBottom="@+id/square3"
android:layout_alignLeft="@+id/recicloEvent"
android:layout_alignTop="@+id/square3"
/>
<View
android:id="@+id/separatorDateRvCale"
android:layout_width="1dp"
android:layout_height="200dp"
android:layout_alignBottom="@+id/square3"
android:layout_alignLeft="@+id/recicloEvent"
android:layout_alignTop="@+id/square3" />
</RelativeLayout>
Upvotes: 0
Reputation: 1506
try putting the whole layout inside a NestedScrollView as follows
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardElevation="1dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/square3"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/square" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:id="@+id/separatorDateRvCale2"
android:layout_width="1dp"
android:layout_height="200dp" />
<View
android:id="@+id/separatorDateRvCale"
android:layout_width="1dp"
android:layout_height="200dp" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recicloEvent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginRight="26dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/lin"
android:layout_weight="1"
android:paddingLeft="1dp" />
<LinearLayout
android:id="@+id/lin"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/day"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/nameeOfMonthTable"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</android.support.v4.widget.NestedScrollView>
Upvotes: 1
Reputation: 580
<android.support.v7.widget.RecyclerView
android:id="@+id/recicloEvent"
android:layout_width="match_parent"
android:layout_height="0dp" //check this must be match_parent or wrap_content
android:layout_marginRight="26dp"
android:layout_marginTop="20dp"
android:layout_toRightOf="@+id/lin"
android:layout_alignBottom="@+id/square3"
android:layout_alignTop="@+id/square3"
android:layout_marginBottom="25dp"
android:paddingLeft="1dp"/>
Upvotes: 0