2016-12-09 45 views
-2

我創建了正常的列表視圖,但它不是用戶友好的。我在谷歌搜索和找到這張圖片的列表視圖,我喜歡這樣創建列表視圖。 我只需要像這樣做拳擊,陰影和3D一樣! enter image description here如何創建像這樣的列表視圖

這是我的XML代碼:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 

    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="center" 
    android:orientation="horizontal" 
    android:padding="5dp" 
    android:divider="#a31405"> 

    <LinearLayout 

     android:layout_width="238dp" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="10dp" 
     android:layout_marginLeft="5dp" 
     android:textDirection="rtl" 
     android:layoutDirection="rtl" 

     android:orientation="vertical" > 

     <TextView 

      android:id="@+id/text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Title" 
      android:layout_gravity="right" 
      android:textDirection="rtl" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:fontFamily="sans-serif" 
      android:textSize="18sp" 
      android:textAlignment="textEnd" /> 

     <TextView 
      android:id="@+id/text_category" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="right" 
      android:text="Category" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 

     <TextView 
      android:id="@+id/second" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="30:00" 
      android:textAppearance="?android:attr/textAppearanceSmall" /> 

    </LinearLayout> 

    <ImageView 
     android:id="@+id/picture" 
     android:layout_width="140dp" 
     android:layout_height="90dp" 
     android:src="@mipmap/ic_launcher" 
     android:scaleType="centerCrop" 
     android:contentDescription="@string/desc"/> 

</LinearLayout> 

我的應用程序是基於Web的應用程序和工作與在線數據庫。 謝謝。

+2

你有什麼迄今所做?你面臨的問題是什麼?這是使用自定義適配器和項目的簡單列表視圖。 – Rohit5k2

+0

@ Rohit5k2需要使這樣的拳擊,陰影和3D一樣!我的listview是非常非常簡單的,只是圖像和文字和分隔線,沒有像這樣的效果。 – user2003857

+0

您需要在選擇它時更改imageView圖像。或者你可以保留兩個圖像與任何圖像,並在一次可見 – Vinodh

回答

0

使用CardView,您可以用卡片方式使用投影(elevation)和corner radius來表示信息,該方式在整個平臺上看起來一致。 CardView擴展了FrameLayout,並支持返回到Android 2.x.

CardViewRecyclerView合併時,您可以實現良好的UI。

請參閱此link

0

您可以使用CardviewRecylerView來獲得陰影ListView。請參閱以下鏈接樣本項目:

Sample1Sample2

相關問題