Grundsätzlich habe ich zwei ähnliche Layouts mit unterschiedlichen Ansatz zu erstellen. Das Problem ist, dass sich RecyclerView
WRAP_CONTENT
auf diesen 2 Layouts anders verhält. Beim ersten Layout funktioniert es gut, bei den anderen funktioniert WRAP_CONTENT
nicht.Nicht WRAP_CONTENT RecyclerView innerhalb LinearLayout
Der folgende Code funktioniert nicht.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
... other layout codes
<android.support.v7.widget.RecyclerView
android:id="@+id/xxx"
style="@style/MarginLeftDetail"
android:layout_width="match_parent"
android:layout_height="0dp"
/>
... other layout codes
</LinearLayout>
Während dies ist derjenige, der funktioniert.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
... other layout codes
<android.support.v7.widget.RecyclerView
android:id="@+id/xxx"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@+id/yyy"
style="@style/MarginLeftDetail"
android:layout_marginTop="7.5dp"/>
... other layout codes
</RelativeLayout>
interpretiert LinearLayout
WRAP_CONTENT
anders als RelativeLayout
?
UPDATE: Wenn ich die erste RecyclerView
mit RelativeLayout
wrap, funktioniert es gut. Also ich denke, LinearLayout
wirklich interpretieren WRAP_CONTENT
anders? Oder ist es ein Fehler?
Danke.
Sie haben folgen weitere Ausgabe Details. Können Sie Screenshot für lineares und relatives Layout veröffentlichen? –