由于新的项目需要支持2.3.3版本的Android机型,额,2.3.3左右的已经份额非常非常小了,
还需要支持,真蛋疼。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
app:backgroundTint="#ff87ffeb"
app:elevation="6dp"
app:pressedTranslationZ="12dp"
app:rippleColor="#33728dff"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|bottom"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
在genymotion上模拟器版本为2.3.7运行的效果还是不错的。
然后在尝试一下CardView在2.3.7上运行的效果:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.v7.widget.CardView
android:id="@+id/cardview"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_margin="8dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="8dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</android.support.v7.widget.CardView>
</RelativeLayout>
可以看到这里可以设置CardView的背景颜色,还有圆角大小。
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="8dp"
还可以看到这里的阴影效果是不需要设置的。其实CardView是继承自FrameLayout,所以使用的时候可以当做FrameLayout来使用。