In android 4.0.4, my card view appears with a false gray underline near the bottom. I can’t seem to get rid of it, I tried messing up the edges and padding etc. but no luck.
Inherit my XML :
android:id="@+id/button_daily_calls"
android:layout_width="@dimen/menu_button_width"
android:layout_height="@dimen/menu_button_height"
android:layout_marginTop="@dimen /top_menu_button_topmargin"
android:layout_marginLeft="@dimen/menu_button_leftmargin"
android:layout_marginRight="0dp"
android:elevation="@dimen/menu_button_elevation"
card_view:cardCornerRadius= "@dimen/menu_button_radius"
card_view:cardUseCompatPadding="true"
android:paddingBottom="0dp">
android:layout_width="match_parent"
android:layout_height="matc h_parent"
android:gravity="center"
android:padding="@dimen/menu_button_padding"
android:text="DAILY CALLS"
android:textSize="@dimen /menu_button_textsize"
android:textColor="@color/colorPrimaryDark"/>
styles.xml:
< br />
< br />
< br />
Dimens.xml :
112dp 6dp 300dp 104dp 8dp 8dp < br />3dp 30dp 20dp 128dp 16dp 4dp 600dp 275dp 3dp 16dp 16dp 80dp -16dp < br />0dp 110dp 230dp 40dp 4dp 12dp 20dp 0dp 200dp 248dp 20sp 6pt 14sp 18sp 3pt 340dp 38dp 2dp 4dp 8dp 12dp 16dp 24dp 32dp 48dp 52dp 85dp 168dp 45dp 10sp 14sp
< dimen name="text_size_large">18sp32sp 42dp
520dp 520dp 112px 112px 85dp 60dp 68dp 320dp 640dp 480dp 240dp 160dp 260dp 160dp 100dp
< dimen name="image_thumbnail_spacing">1dp1dp 240dp
16dp 16dp 16dp 160dp
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardUseCompatPadding="true"< /pre>Same
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardPreventCornerOverlap= "false"This prevents the Corners from overlapping, so that there is no gap between the picture and the CardView.
So it works on all different Android versions, you should do the following:< /p>
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cardView.setPreventCornerOverlap(true);
} else {
cardView.setPreventCornerOverlap(false);
}This should help, because when using Android 4.0.4 there will always be padding around the image. Set cardView.setPreventCornerOverlap(false) Time; it shouldn’t do that.
In android 4.0.4, my card view appears with a false gray underline near the bottom. I can't seem to get rid of it, I tried messing up the edges and padding etc. but nothing Luck.
Inherit my XML:
android:id="@+id/button_daily_calls"
android:layout_width="@dimen/menu_button_width"
android:layout_height="@dimen/menu_button_height"
android:layout_marginTop="@dimen /top_menu_button_topmargin"
android:layout_marginLeft="@dimen/menu_button_leftmargin"
android:layout_marginRight="0dp"
android:elevation="@dimen/menu_button_elevation"
card_view:cardCornerRadius= "@dimen/menu_button_radius"
card_view:cardUseCompatPadding="true"
android:paddingBottom="0dp">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:padding="@dimen/menu_button_padding"
android:text="DAILY CALLS"
android:textSize="@dimen/menu_button_textsize"
android:textColor="@color/colorPrimaryDark"/>
styles.xml:
- true
- false
- @color/colorPrimary
- @color/colorPrimaryDark
- @dimen/appbar_elevation
- false
item>
- @dimen/text_size_medium
- bold
- @color/body_text_1
- end
- @dimen/text_size_medium
- 1.1
- @color/body_text_1
< br />
< br />
< style name="ListItemContainer" parent="style/ListItemContainerBase">
- @color/abs__holo_blue_light
Dimens.xml:
< ?xml version="1.0" encoding="utf-8"?>112dp 6dp 300dp 104dp 8dp 8dp 3dp 30dp 20dp 128dp 16dp 4dp 600dp 275dp 3dp 16dp 16dp
80dp -16dp 0dp 110dp 230dp 40dp 4dp 12dp
< dimen name="dashboard_option_button_top_margin_top">20dp0dp < br />200dp 248dp
< dimen name="font_size_for_pod_row">20sp6pt 14sp
18sp 3pt 340dp 38dp 2dp 4dp 8dp 12dp 16dp < br />24dp 32dp 48dp 52dp 85dp 168dp 45dp 10sp 14sp 18sp 32sp 42dp 520dp 520dp 112px 112px 85dp 60dp 68dp 320dp 640dp 480dp 240dp 160dp 260dp 160dp 100dp 1dp 1dp 240dp 16dp 16dp 16dp 160dp
你尝试过替换吗?
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardUseCompatPadding="true"
同
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardPreventCornerOverlap="false"
这样可以防止Corners重叠,从而在图片和CardView之间没有间隙.
因此它适用于所有不同的Android版本,您应该执行以下操作:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cardView.setPreventCornerOverlap(true);
} else {
cardView.setPreventCornerOverlap(false);
}
这应该会有所帮助,因为在使用Android 4.0.4时,图像周围总会有填充.设置cardView.setPreventCornerOverlap(false)时;它不应该那样做了.