Reputation: 575
Using https://github.com/gabrielemariotti/cardslib, I want a layout that looks like the following:
----------- (this card has dynamic text
|this is | and its height should adjust
|a card | to the amount of text automatically)
-----------
=========== (separator)
-----------
|this is |
|a |
|CardsList|
-----------
Here's what I have right now:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/wrapper">
<it.gmariotti.cardslib.library.view.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#ddd"
android:layout_below="@+id/wrapper"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<it.gmariotti.cardslib.library.view.CardListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/match_ongoing_hand"
android:layout_below="@+id/list" />
</RelativeLayout>
The problem is the LinearLayout takes up the entire screen, even if there is only a small amount of text in the top card. If I set the LinearLayout to a specific layout_height, I can see the CardListView. In CardListView, cards naturally wrap to their text. I'd like the LinearLayout to wrap to the top card's height. How can I achieve this? Thanks.
Upvotes: 1
Views: 459
Reputation: 39191
I think this layout should do what you want:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<it.gmariotti.cardslib.library.view.CardView
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ddd"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<it.gmariotti.cardslib.library.view.CardListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/match_ongoing_hand" />
</LinearLayout>
Also, I think you can safely remove the layout_alignParentLeft
and layout_alignParentStart
attributes from the divider View
.
Upvotes: 1