【发布时间】:2015-04-09 13:55:01
【问题描述】:
我有一个 ViewPager,其中包含几个片段,可通过向左/向右滑动来获得。我希望这些片段看起来像卡片,但我似乎无法正确处理。
碎片占据了整个空间,阴影围绕着卡片。相反,我想在片段布局和 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>
谁能帮我解决这个问题?谢谢!
【问题讨论】:
标签: android xml layout android-fragments background