2017-05-29 33 views
2

我有一個帶CardView的回收站。即使我沒有明確地指定高程,當項目到達屏幕的底部,海拔也會增加。在其他地方沒有看到這種行爲,這可能是由什麼引起的?海拔隨列表位置增加

enter image description here

<android.support.v7.widget.CardView 
    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:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/card_layout" 
    app:cardElevation="6dp" 
    app:cardPreventCornerOverlap="false" 
    app:cardUseCompatPadding="true" 
    android:foreground="?android:attr/selectableItemBackground" 
    android:fitsSystemWindows="true" 
    android:layout_marginLeft="4dp" 
    android:layout_marginRight="4dp" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/schedule_card_height" 
     android:orientation="horizontal"> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1"> 

      <TextView 
       android:id="@+id/schedule_item_category" 
       style="@style/Base.TextAppearance.AppCompat.Caption" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:background="@drawable/background_eventlist_category" 
       android:gravity="center" 
       android:padding="5dp" 
       android:textAllCaps="true" 
       tools:text="Interview"/> 
     </RelativeLayout> 

     <View android:layout_height="match_parent" 
       android:layout_width="1dp" 
       android:background="@color/colorIcons" 

       /> 

     <RelativeLayout 
      android:id="@+id/schedule_item_actions" 
      android:layout_width="0dp" 
      android:layout_weight="2" 
      android:layout_height="wrap_content" 
      android:background="@drawable/rounded_white" 
      android:padding="12dp"> 

      <ProgressBar 
       android:id="@+id/schedule_item_progress" 
       style="?android:attr/progressBarStyle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentRight="true" 
       android:visibility="gone"/> 


      <TextView 
       android:id="@+id/schedule_item_title" 
       style="@style/TextAppearance.AppCompat.Subhead" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="top|center_vertical" 
       android:layout_alignParentLeft="true" 
       android:layout_above="@+id/schedule_item_date" 
       android:layout_alignParentTop="true" 
       android:layout_toLeftOf="@+id/schedule_item.popup" 
       android:ellipsize="end" 
       android:maxLines="2" 
       tools:text="Awesome event because i say so"/> 

      <TextView 
       android:id="@+id/schedule_item_date" 
       style="@style/TextAppearance.AppCompat.Caption" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center_vertical" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentEnd="true" 
       android:layout_alignParentBottom="true" 
       android:ellipsize="end" 
       android:textAllCaps="true" 
       android:maxLines="1" 
       tools:text="25th April, 5PM (GMT)"/> 

      <ImageView 
       android:id="@+id/schedule_item.popup" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentEnd="true" 
       android:src="@drawable/ic_dots"/> 

     </RelativeLayout> 

    </LinearLayout> 

</android.support.v7.widget.CardView> 
+0

請顯示您的XML佈局文件。 –

+0

顯示你的xml代碼。嘗試把'useCompatPadding true'並設置標高爲1,2或等 –

+0

我剛剛發佈它 – MichelReap

回答

-3

的光附近的某處裝置的頂部,向顯示器向下傾斜,所以該項目是所述下,越大陰影距離。

+0

我認爲。他正在使用自拍閃光燈..:D但是邏輯是堅實的。 –

0
<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:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 
     <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/card_layout" 
      app:cardElevation="6dp" 
      app:cardPreventCornerOverlap="false" 
      app:cardUseCompatPadding="true" 
      android:foreground="?android:attr/selectableItemBackground" 
      android:fitsSystemWindows="true" 
      android:layout_marginLeft="4dp" 
      android:layout_marginRight="4dp" 
      > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="@dimen/schedule_card_height" 
       android:orientation="horizontal"> 

       <RelativeLayout 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1"> 

        <TextView 
         android:id="@+id/schedule_item_category" 
         style="@style/Base.TextAppearance.AppCompat.Caption" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         android:background="@drawable/background_eventlist_category" 
         android:gravity="center" 
         android:padding="5dp" 
         android:textAllCaps="true" 
         tools:text="Interview"/> 
       </RelativeLayout> 

       <View android:layout_height="match_parent" 
         android:layout_width="1dp" 
         android:background="@color/colorIcons" 

         /> 

       <RelativeLayout 
        android:id="@+id/schedule_item_actions" 
        android:layout_width="0dp" 
        android:layout_weight="2" 
        android:layout_height="wrap_content" 
        android:background="@drawable/rounded_white" 
        android:padding="12dp"> 

        <ProgressBar 
         android:id="@+id/schedule_item_progress" 
         style="?android:attr/progressBarStyle" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentRight="true" 
         android:visibility="gone"/> 


        <TextView 
         android:id="@+id/schedule_item_title" 
         style="@style/TextAppearance.AppCompat.Subhead" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:gravity="top|center_vertical" 
         android:layout_alignParentLeft="true" 
         android:layout_above="@+id/schedule_item_date" 
         android:layout_alignParentTop="true" 
         android:layout_toLeftOf="@+id/schedule_item.popup" 
         android:ellipsize="end" 
         android:maxLines="2" 
         tools:text="Awesome event because i say so"/> 

        <TextView 
         android:id="@+id/schedule_item_date" 
         style="@style/TextAppearance.AppCompat.Caption" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" 
         android:gravity="center_vertical" 
         android:layout_alignParentLeft="true" 
         android:layout_alignParentEnd="true" 
         android:layout_alignParentBottom="true" 
         android:ellipsize="end" 
         android:textAllCaps="true" 
         android:maxLines="1" 
         tools:text="25th April, 5PM (GMT)"/> 

        <ImageView 
         android:id="@+id/schedule_item.popup" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_alignParentEnd="true" 
         android:src="@drawable/ic_dots"/> 

       </RelativeLayout> 

      </LinearLayout> 

     </android.support.v7.widget.CardView> 
      </LinearLayout> 
+0

這基本上是把一個LinearLayout包裝CardView的權利? – MichelReap

+0

yup ................................ –

+0

工作與否我沒有試過這@我的方式.. ... @ MichelReap –