Reputation: 1314
I'm using CardStackView in my app. I've edited the layout so I can get a full height card when a card is selected.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:id="@+id/linear_list_card_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:stackHeaderHeight="160dp">
<FrameLayout
android:id="@+id/frame_list_card_item"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.99"
android:background="@drawable/shape_rectangle_with_radius">
<TextView
android:id="@+id/text_list_card_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textColor="@android:color/white"
android:textSize="40sp"
android:textStyle="bold"
tools:text="12" />
</FrameLayout>
<View
android:id="@+id/gab"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.01"
android:animateLayoutChanges="true">
</View>
</LinearLayout>
What I'm trying to do is to add a space between the selected card and the stack under it.
Upvotes: 0
Views: 400
Reputation: 508
I am trying to answer this question, once upon a time, I have faced this.
You have to provide the height of the card using PercentRelativeLayout.
<android.support.percent.PercentRelativeLayout 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:id="@+id/linear_list_card_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:stackHeaderHeight="160dp">
<FrameLayout
android:id="@+id/frame_list_card_item"
android:layout_width="match_parent"
android:background="@drawable/shape_rectangle_with_radius"
app:layout_heightPercent="90%">
<TextView
android:id="@+id/text_list_card_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textColor="@android:color/white"
android:textSize="40sp"
android:textStyle="bold"
tools:text="12" />
</FrameLayout>
<View
android:id="@+id/gab"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.01"
android:animateLayoutChanges="true"
android:visibility="gone">
</View>
</android.support.percent.PercentRelativeLayout>
Don't forget to add this line in build.gradle (Module:app)
dependencies {
compile 'com.android.support:percent:23.3.0'
}
Upvotes: 1