Use a custom style for all CardViews

This fixes the crash in Lollipop when setting cardBackgroundColor manually

Closes #47
This commit is contained in:
Jakob Nixdorf 2017-10-14 13:06:16 +02:00
parent 44912927e0
commit 98061314a6
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
3 changed files with 46 additions and 41 deletions

View file

@ -1,15 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardBackgroundColor="?cardBackgroundColor"
card_view:cardUseCompatPadding="true"
card_view:cardCornerRadius="@dimen/card_corner_radius"
card_view:contentPadding="@dimen/activity_margin"
>
style="?attr/cardStyle" >
<LinearLayout
android:orientation="horizontal"

View file

@ -17,15 +17,13 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_margin"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardElevation="@dimen/card_elevation" >
style="?attr/cardStyle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin" >
android:paddingBottom="@dimen/activity_margin_small" >
<LinearLayout
android:orientation="horizontal"
@ -68,22 +66,20 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_margin"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardElevation="@dimen/card_elevation" >
style="?attr/cardStyle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin" >
android:orientation="vertical" >
<!-- version -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -123,7 +119,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -163,7 +160,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -190,7 +188,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -217,7 +216,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -244,20 +244,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_margin"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardElevation="@dimen/card_elevation" >
style="?attr/cardStyle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin" >
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:text="@string/about_title_authors"/>
<!-- 1st author -->
@ -265,8 +261,9 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin"
android:padding="@dimen/activity_margin_small"
android:layout_marginTop="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -339,7 +336,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -413,7 +411,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -440,7 +439,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -468,20 +468,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_margin"
app:cardBackgroundColor="?cardBackgroundColor"
app:cardElevation="@dimen/card_elevation" >
style="?attr/cardStyle" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/activity_margin"
android:paddingBottom="@dimen/activity_margin" >
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/activity_margin"
android:text="@string/about_title_support"/>
<!-- bug reports -->
@ -491,7 +487,8 @@
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:layout_marginTop="@dimen/activity_margin"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >
@ -531,7 +528,8 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="@dimen/activity_margin_small"
android:paddingTop="@dimen/activity_margin_small"
android:paddingBottom="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical" >

View file

@ -1,6 +1,7 @@
<resources>
<!-- Definitions -->
<attr name="windowBackground" format="reference" />
<attr name="cardStyle" format="reference" />
<attr name="colorGithub" format="reference" />
<attr name="colorPaypal" format="reference" />
@ -19,7 +20,7 @@
<item name="colorGithub">@color/github_dark</item>
<item name="colorPaypal">@color/paypal_dark</item>
<item name="cardBackgroundColor">?android:colorBackgroundFloating</item>
<item name="cardStyle">@style/CardViewStyle</item>
</style>
<style name="AppTheme.NoActionBar">
@ -27,6 +28,13 @@
<item name="windowNoTitle">true</item>
</style>
<style name="CardViewStyle" parent="CardView">
<item name="cardCornerRadius">@dimen/card_corner_radius</item>
<item name="cardUseCompatPadding">true</item>
<item name="contentPadding">@dimen/activity_margin</item>
<item name="cardElevation">@dimen/card_elevation</item>
</style>
<!-- Dark application theme. -->
<style name="AppTheme.Dark" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
@ -38,7 +46,7 @@
<item name="colorGithub">@color/github_light</item>
<item name="colorPaypal">@color/paypal_light</item>
<item name="cardBackgroundColor">?android:colorBackgroundFloating</item>
<item name="cardStyle">@style/CardViewStyle</item>
</style>
<style name="AppTheme.Dark.NoActionBar">
@ -57,6 +65,10 @@
<item name="colorGithub">@color/github_light</item>
<item name="colorPaypal">@color/paypal_light</item>
<item name="cardStyle">@style/CardViewStyle.Black</item>
</style>
<style name="CardViewStyle.Black">
<item name="cardBackgroundColor">@android:color/black</item>
</style>