2017-06-20 8 views
0

私のアプリでCardStackViewを使用しています。レイアウトを編集して、カードが選択されたときに完全な高さのカードを得ることができます。Android: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> 

私がしようとしているのは、選択したカードとその下のスタックの間にスペースを追加することです。 How can I get the required output?

答えて

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にこの行を追加することを忘れないでください(モジュール:アプリ)

dependencies { 
    compile 'com.android.support:percent:23.3.0' 
} 
関連する問題