我在我的应用中使用CardStackView。我已经编辑了布局,所以当选择卡片时我可以获得一张全高卡。
<?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>
答案 0 :(得分:1)
我试图回答这个问题,从前,我已经面对这个了。
您必须使用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>
不要忘记在build.gradle中添加此行(Module:app)
dependencies {
compile 'com.android.support:percent:23.3.0'
}