我正在玩新的CardView,但邊距似乎沒有應用。CardView layout_margin不起作用
<?xml version="1.0" encoding="utf-8"?>
<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_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
card_view:cardCornerRadius="4dp"
card_view:cardBackgroundColor="#FFA"
card_view:layout_margind="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/info_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"/>
</LinearLayout>
</android.support.v7.widget.CardView>
順便說一句,我用它在ViewPager中的片段。即使我在CardView上使用android:layout_marginLeft =「18dp」和android:layout_marginRight =「18dp」,該卡也會擴展整個屏幕寬度(match_parent)。
任何想法我可能做錯了什麼?
在那裏我會使用這些代碼?我正在使用FragmentStatePagerAdapter。 –
當你膨脹的觀點,在片段或適配器。 –
這工作對我來說 – yeahdixon