2017-06-15 45 views
1

額外的空間,我已經創建了下面移除cardview

enter image description here

我的代碼cardview是: -

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:id="@+id/card_view" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:layout_margin="5dp" 
card_view:cardCornerRadius="4dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="160dp" 
    android:orientation="vertical" 
    android:weightSum="4"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_horizontal"> 

     <ImageView 
      android:id="@+id/thumbnail" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:scaleType="centerCrop" 
      /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left|bottom" 
      android:background="@android:drawable/screen_background_dark_transparent" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="16dp" 
       android:textSize="16dp" 
       android:textColor="#FFFFFF" 
       android:textStyle="bold" /> 

      <TextView 
       android:id="@+id/count" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/title" 
       android:paddingBottom="@dimen/songs_count_padding_bottom" 
       android:visibility="invisible" 
       android:paddingLeft="@dimen/album_title_padding" 
       android:paddingRight="@dimen/album_title_padding" 
       android:textSize="@dimen/songs_count" /> 
     </LinearLayout> 
    </FrameLayout> 
</LinearLayout> 

我想從左邊刪除空間額外的空間,右,如下圖所示的頂部和底部: -

enter image description here

我該怎麼做dis?

+0

'機器人:layout_margin =「5DP」''中可能CardView'是問題 –

+0

我也刪除,但一切都沒有改變 –

+0

@ManishaKhatke清理重建和運行 –

回答

0

安卓layout_margin

指定上來看4側額外的空間。

XML刪除以下房產

android:layout_margin="5dp". 

編輯

<ImageView 
     android:id="@+id/thumbnail" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center" 
     android:scaleType="centerCrop" //REMOVE this 
     /> 
1

Cardview刪除android:layout_margin="5dp「。

+0

我已刪除它,但沒有任何變化 –

+0

刪除保證金後請張貼截圖。 –

+0

請確保您定義回收站視圖的主佈局沒有邊距或填充。如果有,請刪除。 –

0

試試這個代碼:

<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:card_view="http://schemas.android.com/apk/res-auto" 
android:id="@+id/card_view" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
card_view:cardCornerRadius="4dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="160dp" 
    android:orientation="vertical" 
    android:weightSum="4"> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_gravity="center_horizontal"> 

     <ImageView 
      android:id="@+id/thumbnail" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_gravity="center" 
      android:scaleType="centerCrop" 
      /> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="left|bottom" 
      android:background="@android:drawable/screen_background_dark_transparent" 
      android:orientation="vertical"> 

      <TextView 
       android:id="@+id/title" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:padding="16dp" 
       android:textSize="16dp" 
       android:textColor="#FFFFFF" 
       android:textStyle="bold" /> 

      <TextView 
       android:id="@+id/count" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/title" 
       android:paddingBottom="@dimen/songs_count_padding_bottom" 
       android:visibility="invisible" 
       android:paddingLeft="@dimen/album_title_padding" 
       android:paddingRight="@dimen/album_title_padding" 
       android:textSize="@dimen/songs_count" /> 
     </LinearLayout> 
    </FrameLayout> 
</LinearLayout> 
+0

它不起作用 –

+0

它在回收站視圖或列表視圖中嗎? –

+0

它在回收站視圖 –