Android Material 在 Cardview 上显示全屏图像的 CardView
Android Material CardView with full screen image on Cardview
我需要这样做:
http://developer.android.com/design/material/images/card_travel.png
所以我创建并将依赖项添加到项目中,这是我的 activity 主要代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="6dp">
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:src="@drawable/ic"/>
<TextView
style="@style/TextAppearance.AppCompat.Caption"
android:textColor="#555"
android:layout_margin="3dp"
android:gravity="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detail"/>
</android.support.v7.widget.CardView>
</LinearLayout>
所以,我们如何才能像下图那样做到这一点:?
http://i.stack.imgur.com/Z0lNa.png
干杯!
您要找的是半透明状态栏。当你有这个配置时,你就可以达到这个效果。还要确保按照我在下面的示例中所做的那样删除操作栏,否则你必须将其设置为透明。
将您的 v21/themes.xml 文件更改为:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
然后将 android:fitsSystemWindows="true" 添加到您的 LinearLayout。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
我需要这样做:
http://developer.android.com/design/material/images/card_travel.png
所以我创建并将依赖项添加到项目中,这是我的 activity 主要代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_margin="6dp">
<ImageView
android:layout_width="100dp"
android:layout_height="50dp"
android:src="@drawable/ic"/>
<TextView
style="@style/TextAppearance.AppCompat.Caption"
android:textColor="#555"
android:layout_margin="3dp"
android:gravity="end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Detail"/>
</android.support.v7.widget.CardView>
</LinearLayout>
所以,我们如何才能像下图那样做到这一点:?
http://i.stack.imgur.com/Z0lNa.png
干杯!
您要找的是半透明状态栏。当你有这个配置时,你就可以达到这个效果。还要确保按照我在下面的示例中所做的那样删除操作栏,否则你必须将其设置为透明。
将您的 v21/themes.xml 文件更改为:
<style name="Theme.MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
然后将 android:fitsSystemWindows="true" 添加到您的 LinearLayout。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/feed_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">