2017-05-08 70 views
0

如何實現這個設計? design 我目前的設計實現看起來像這樣,如何去除黑色空間? currentImplementation 我回收鑑於當前的代碼android recyclerview center horizo​​ntal items

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <FrameLayout 
      android:id="@+id/gesture_layout" 
      android:layout_width="fill_parent" 
      android:layout_height="260dp" 
      android:background="@color/white" 
      android:orientation="horizontal"> 

      <android.support.v7.widget.RecyclerView 
       android:id="@+id/recycler_view" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_centerHorizontal="true" 
       android:background="@color/transparent" 
       android:gravity="center_horizontal" 
       android:clipToPadding="false" 
       android:visibility="visible" 
       /> 

     </FrameLayout> 
    </LinearLayout> 

我cardView

的當前代碼
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@color/black" 
    android:layout_gravity="center_horizontal" 
    > 

    <!-- A CardView that contains a GifImageView --> 
    <android.support.v7.widget.CardView 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/card_view" 
     android:layout_gravity="center" 
     android:layout_width="68dp" 
     android:layout_height="68dp" 
     card_view:cardCornerRadius="0dp" 
     card_view:cardMaxElevation="0dp" 
     card_view:cardElevation="0dp" 
     card_view:cardBackgroundColor="@color/tab_selected" 
     > 

     <pl.droidsonroids.gif.GifImageView 
      android:id="@+id/emoji" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/transparent" 
      /> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 
+0

嘗試增加的android:layout_width = 「68dp」 和android:layout_height = 「68dp」 到你的LinearLayout – FAT

+0

我添加的android:layout_width = 「68dp」 和android:layout_height = 「68dp」我的LinearLayout但空間不能刪除,現在的空間是白色 –

+0

發佈您的Java代碼爲這recyclerview – FAT

回答

0

添加android:layout_width="68dp"android:layout_height="68dp"LinearLayout

2.刪除行mRecyclerView.addItemDecoration(new SpacesItemDecoration(10, context));或使用較小的差距。

3.添加屬性card_view:cardUseCompatPadding="false"CardView

試試這個:

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="68dp" 
    android:layout_height="68dp" 
    android:background="@color/black" 
    android:layout_gravity="center_horizontal"> 

    <!-- A CardView that contains a GifImageView --> 
    <android.support.v7.widget.CardView 
     xmlns:card_view="http://schemas.android.com/apk/res-auto" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/card_view" 
     android:layout_gravity="center" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     card_view:cardCornerRadius="0dp" 
     card_view:cardMaxElevation="0dp" 
     card_view:cardElevation="0dp" 
     card_view:cardBackgroundColor="@color/tab_selected" 
     card_view:cardUseCompatPadding="false"> 

     <pl.droidsonroids.gif.GifImageView 
      android:id="@+id/emoji" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="@color/transparent"/> 
    </android.support.v7.widget.CardView> 
</LinearLayout> 
相關問題