Ich habe eine recyclerView in meinem LinearLayout.RecyclerView in einem LinearLayout zusammen mit mehreren anderen Ansichten
<ScrollView 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:id="@+id/book_detail_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.BookDetailActivity">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:orientation="vertical">
<ImageView
android:layout_width="250dp"
android:layout_height="270dp"
android:id="@+id/book_image"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_gravity="center"
android:src="@drawable/book_default"/>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="#EEEEEE"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/book_authors"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:fontFamily="sans-serif-condensed" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleSmall"
android:max="5"
android:id="@+id/book_rating"
android:stepSize="0.5"
android:paddingTop="10dp"
android:isIndicator="true"
android:progressTint="#FFA500"
android:secondaryProgressTint="#D1D6D8"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingLeft="5dp"
android:id="@+id/book_rating_text"
android:fontFamily="sans-serif-condensed" />
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:id="@+id/book_reviews_text"
android:textColor="@color/redColor"
android:fontFamily="sans-serif-condensed" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="#EEEEEE"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:fadingEdge="vertical"
android:fadingEdgeLength="20dp"
android:paddingTop="@dimen/activity_vertical_margin"
android:id="@+id/book_description"
android:onClick="toggleText"
android:ellipsize="end"
android:maxLines="3" />
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:id="@+id/book_description_below_line"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:background="#EEEEEE"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/dark_translucent_black"
android:textAlignment="center"
android:textSize="15dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="People near you who are willing to lend this book"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/lender_recycler_view"
android:layout_width="match_parent"
android:layout_height="400dp"
android:scrollbars="vertical" />
</LinearLayout>
</ScrollView>
Das Problem ist, dass, wenn ich diese recyclerView aufblasen, die komplette Aktivität nicht scrollt (Nur der Teil der Recycler Ansicht der Fall ist). Außerdem habe ich die Höhe von recyclerView angegeben, sonst kann ich es nicht sehen.
Also meine beiden Probleme sind:
- Wie diese RecyclerView Höhe dynamisch geben (
layout_height: wrap_content
nicht funktioniert) - Wie die gesamte Aktivität zu bewegen (und nicht nur die recyclerView Teil) wenn Inhalt mehr ist.
PS Ich bin neu in Android, obwohl ich früher recyclerView umgesetzt haben, aber in diesen Fällen gab es nur ein Element (ein recyclerView innerhalb eines übergeordneten Linearlayout)
@ b1izzard ich auch diesen Beitrag gefunden hatte, aber Sie können mir sagen, warum wrap_content ist hier nicht arbeiten, Gibt es keinen anderen Weg, als Höhe aus Java-Datei zu setzen? – Abhishek
Welchen LayoutManager verwenden Sie? – AbhayBohra
@Abhay LinearLayoutManager – Abhishek