0
我有一個ViewPager,其中包含一些可通過向左/向右滑動的片段。我希望這些碎片看起來像卡片,但我似乎無法做到。Android:將卡片設計爲片段
片段佔據整個空間和陰影周圍的卡。相反,我希望在片段佈局和ViewPager之間有一些填充,所以當我滾動時,片段之間會有一些空間。這是我希望它看起來像或多或少
這是我的片段佈局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".Main"
android:layout_marginLeft="25dp"
android:layout_marginRight="25dp"
android:layout_marginTop="35dp"
android:layout_marginBottom="35dp"
android:background="@drawable/bg_card"
>
<EditText
android:layout_marginTop="100dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number" />
<EditText
android:layout_marginTop="150dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number" />
<EditText
android:layout_marginTop="50dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="number" />
</RelativeLayout>
這是該卡可繪製:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp"/>
<solid android:color="#aaa" />
<padding android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp" />
<solid android:color="#fff" />
<padding android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp" />
</shape>
</item>
</layer-list>
誰能幫我這個?謝謝!
是不是這只是5.0版本?或者它也可以用於早期版本? – 2015-02-09 18:09:18
支持庫小部件向後兼容!雖然您需要閱讀CardView的文檔以查看可能存在的差異(例如,5.0具有提升,但CardView通過調整陰影大小模擬5.0版設備上的提升) – ekchang 2015-02-09 18:15:35
您是對的。我確實設法包括圖書館並創建了該卡。謝謝! – 2015-02-09 18:54:02