簡體   English   中英

Android:在CardStackView中的堆棧和當前卡之間添加空間

[英]Android: Add space between stack and current card in CardStackView

我在我的應用程序中使用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>

我正在嘗試做的是在所選卡與其下面的堆棧之間添加一個空間。 如何獲得所需的輸出?

我試圖回答這個問題,曾幾何時,我曾經面對過這個問題。

您必須使用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'
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM