在android 4.0.4中,我的卡片视图出现在底部附近的虚假灰色下划线.我似乎无法摆脱它,我尝试弄乱边缘和填充等但没有运气. 继承我的XML: android.support.v7.widget.CardView xmlns:card_view="http://sch
在android 4.0.4中,我的卡片视图出现在底部附近的虚假灰色下划线.我似乎无法摆脱它,我尝试弄乱边缘和填充等但没有运气.
继承我的XML:
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" 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"> <TextView 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"/> </android.support.v7.widget.CardView>
styles.xml:
<style name="Theme.IntelliDroid" parent="@style/Theme.AppCompat.Light.NoActionBar"> <item name="windowNoTitle">true</item> <item name="windowActionBar">false</item> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <!--<item name="android:displayOptions">showHome|useLogo</item> <item name="hagDividerVertical">@drawable/breadcrumb_themed_divider</item> <item name="hagSelectableItemBackground">@drawable/breadcrumb_themed_item_background</item>--> <item name="elevation">@dimen/appbar_elevation</item> <item name="android:windowFullscreen">false</item> </style> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="menu_labels_style"> <item name="android:background">@drawable/fab_label_background</item> <item name="android:textColor">@color/white</item> </style> <style name="ProgressBarAppTheme" parent="android:Widget.ProgressBar.Horizontal"> <item name="android:progressDrawable">@drawable/progress_horizontal_holo_light</item> <item name="android:indeterminateDrawable"> @drawable/progress_indeterminate_horizontal_holo_light </item> <item name="android:minHeight">16dip</item> <item name="android:maxHeight">16dip</item> </style> <style name="Dialog" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowBackground">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">true</item> </style> <style name="DialogText"> <item name="android:textSize">16sp</item> </style> <style name="DialogText.Bold" parent="DialogText"> <item name="android:textStyle">bold</item> </style> <style name="DialogText.Title"> <item name="android:textSize">@dimen/text_size_large</item> <item name="android:textStyle">bold</item> <item name="android:layout_marginLeft">@dimen/tab_side_padding_medium</item> <item name="android:layout_marginBottom">@dimen/tab_side_padding_medium</item> </style> <style name="AlertText"> <item name="android:textSize">@dimen/text_size_xlarge</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/unavailable</item> <item name="android:paddingTop">@dimen/tab_side_padding_medium</item> <item name="android:paddingBottom">@dimen/tab_side_padding_medium</item> <item name="android:layout_marginLeft">@dimen/tab_side_padding_medium</item> <item name="android:layout_marginBottom">@dimen/tab_side_padding_medium</item> </style> <style name="TextHeaderListRowLarge" parent="TextHeaderListRow"> <item name="android:textSize">@dimen/text_size_large</item> </style> <style name="TextHeaderListRow"> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:paddingLeft">15dp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="TextHeader"> <item name="android:gravity">center_horizontal</item> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> <item name="android:ellipsize">end</item> </style> <style name="TextHeader_Secondary"> <item name="android:textSize">@dimen/text_size_xlarge</item> <item name="android:textStyle">bold</item> </style> <style name="TextHeaderBold"> <item name="android:textSize">@dimen/text_size_large</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="TextHeaderBoldXLarge"> <item name="android:textSize">@dimen/text_size_xlarge</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="TextHeaderBoldCentered" parent="TextHeaderBold"> <item name="android:gravity">center_horizontal|center_vertical</item> </style> <style name="TextHeaderLightCentered"> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textColor">@color/body_text_2</item> <item name="android:gravity">center_horizontal|center_vertical</item> </style> <style name="TextHeaderLight"> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textColor">@color/body_text_2</item> </style> <style name="TextBody"> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:lineSpacingMultiplier">1.1</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="PushButton"> <item name="android:textSize">@dimen/text_size_small</item> </style> <style name="SalesHistoryValue" parent="TextHeaderBold"> <item name="android:width">125dp</item> <item name="android:paddingLeft">@dimen/tab_side_padding_medium</item> <item name="android:paddingRight">@dimen/tab_side_padding_medium</item> </style> <style name="ButtonText"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textColor">#ffffff</item> <item name="android:gravity">center</item> <item name="android:layout_margin">3dp</item> <item name="android:textSize">30dp</item> <item name="android:textStyle">bold</item> <item name="android:shadowColor">#000000</item> <item name="android:shadowDx">1</item> <item name="android:shadowDy">1</item> <item name="android:shadowRadius">2</item> </style> <style name="ListItemContent"> <item name="android:paddingLeft">10dp</item> <item name="android:paddingRight">10dp</item> <item name="android:paddingTop">8dp</item> <item name="android:paddingBottom">8dp</item> </style> <style name="ListItemTextHeaderNoPadding"> <item name="android:textSize">@dimen/text_size_medium</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="ListItemTextHeader" parent="ListItemTextHeaderNoPadding"> <item name="android:paddingLeft">15dp</item> </style> <style name="ListItemTextHeaderSub" parent="ListItemTextHeader"> <item name="android:textColor">@color/body_text_2</item> </style> <style name="ListItemTextBodyHeader"> <item name="android:textSize">@dimen/text_size_small</item> <item name="android:paddingLeft">15dp</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/body_text_1</item> </style> <style name="ListItemTextBody" parent="ListItemTextBodyHeader"> <item name="android:textColor">@color/body_text_2</item> </style> <style name="ListItemImage"> <item name="android:paddingLeft">@dimen/tab_side_padding</item> <item name="android:paddingTop">@dimen/tab_side_padding</item> <item name="android:paddingBottom">@dimen/tab_side_padding</item> </style> <style name="TreeViewListStyle" parent="@android:attr/listViewStyle"> <item name="android:background">@android:color/white</item> <item name="android:divider">@drawable/divider</item> </style> <style name="UnreadCount"> <item name="android:textSize">18.0sp</item> <item name="android:textColor">@color/body_text_2</item> <item name="android:gravity">center_vertical</item> <item name="android:paddingTop">4.0dip</item> <item name="android:paddingBottom">4.0dip</item> <item name="android:paddingLeft">@dimen/tab_side_padding_large</item> <item name="android:minLines">2</item> <item name="android:includeFontPadding">true</item> </style> <style name="ListItemContainerBase"> <item name="android:minHeight">?android:attr/listPreferredItemHeight</item> </style> <!-- a simple list item is one whose container and content are the same view --> <style name="SimpleListItem" parent="style/ListItemContainerBase"> <item name="android:paddingLeft">10dp</item> <item name="android:paddingRight">10dp</item> <item name="android:paddingTop">8dp</item> <item name="android:paddingBottom">8dp</item> </style> <!-- used for more complex list items, e.g. those with stars aligned to the top-right --> <style name="ListItemContainer" parent="style/ListItemContainerBase"> <item name="android:background">@color/abs__holo_blue_light</item> </style> <style name="ScannerStep"> <item name="android:background">@android:drawable/editbox_background</item> <item name="android:paddingBottom">@dimen/tab_side_padding_medium</item> </style> <style name="HistoryRow" parent="style/ListItemContainerBase"> <item name="android:padding">@dimen/tab_side_padding_medium</item> <item name="android:background">@drawable/background_bottom_border</item> </style> <style name="ChartLabel"> <item name="android:textColor">@color/accent_1</item> </style> <style name="BorderedLayout"> <item name="android:background">@drawable/layout_bordered_background</item> <item name="android:padding">@dimen/tab_side_padding_medium</item> </style>
Dimens.xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="appbar_dashboard_height">112dp</dimen> <dimen name="appbar_elevation">6dp</dimen> <dimen name="menu_button_width">300dp</dimen> <dimen name="menu_button_height">104dp</dimen> <dimen name="menu_button_elevation">8dp</dimen> <dimen name="menu_button_image_elevation">8dp</dimen> <dimen name="menu_button_radius">3dp</dimen> <dimen name="menu_button_padding">30dp</dimen> <dimen name="menu_button_textsize">20dp</dimen> <dimen name="top_menu_button_topmargin">128dp</dimen> <dimen name="menu_button_leftmargin">16dp</dimen> <dimen name="menu_button_topmargin">4dp</dimen> <dimen name="twitter_container_width">600dp</dimen> <dimen name="twitter_container_height">275dp</dimen> <dimen name="twitter_container_radius">3dp</dimen> <dimen name="twitter_container_left_margin">16dp</dimen> <dimen name="twitter_container_right_margin">16dp</dimen> <!--<dimen name="twitter_container_top_margin">88dp</dimen>--> <dimen name="twitter_container_top_margin">80dp</dimen> <dimen name="twitter_container_bottom_margin">-16dp</dimen> <dimen name="sync_status_container_left_margin">0dp</dimen> <dimen name="sync_status_container_top_margin">110dp</dimen> <dimen name="dashboard_option_button_width">230dp</dimen> <dimen name="dashboard_option_button_height">40dp</dimen> <dimen name="dashboard_option_button_radius">4dp</dimen> <dimen name="dashboard_option_button_margin_top">12dp</dimen> <dimen name="dashboard_option_button_top_margin_top">20dp</dimen> <dimen name="dashboard_option_button_left_margin">0dp</dimen> <dimen name="dunno_container_width">200dp</dimen> <dimen name="reconciler_container_height">248dp</dimen> <dimen name="font_size_for_pod_row">20sp</dimen> <dimen name="vertical_padding_for_pod_row">6pt</dimen> <dimen name="font_size_for_show_row">14sp</dimen> <dimen name="font_size_for_pod_details">18sp</dimen> <dimen name="vertical_padding_for_show_row">3pt</dimen> <dimen name="standard_dialog_width">340dp</dimen> <dimen name="tab_height">38dp</dimen> <dimen name="tab_side_padding">2dp</dimen> <dimen name="tab_side_padding_small">4dp</dimen> <dimen name="tab_side_padding_medium">8dp</dimen> <dimen name="tab_side_padding_mediumlarge">12dp</dimen> <dimen name="tab_side_padding_large">16dp</dimen> <dimen name="tab_side_padding_xlarge">24dp</dimen> <dimen name="tab_side_padding_xxlarge">32dp</dimen> <dimen name="tab_side_padding_xxxlarge">48dp</dimen> <dimen name="tab_side_padding_dashboard">52dp</dimen> <dimen name="tab_side_padding_dashboard_top">85dp</dimen> <dimen name="menu_image_padding_large">168dp</dimen> <dimen name="actionbar_compat_height">45dp</dimen> <dimen name="text_size_small">10sp</dimen> <dimen name="text_size_medium">14sp</dimen> <dimen name="text_size_large">18sp</dimen> <dimen name="text_size_xlarge">32sp</dimen> <dimen name="drawer_height">42dp</dimen> <dimen name="signature_capture_width">520dp</dimen> <dimen name="previous_comments_popup_width">520dp</dimen> <dimen name="social_image_maxwidth">112px</dimen> <dimen name="social_image_maxheight">112px</dimen> <dimen name="twitter_content_height">85dp</dimen> <dimen name="list_row_order_height">60dp</dimen> <dimen name="list_row_sales_item_width">68dp</dimen> <dimen name="survey_question_width">320dp</dimen> <dimen name="survey_question_width_text">640dp</dimen> <dimen name="popup_maps_width">480dp</dimen> <dimen name="popup_maps_streetview_width">240dp</dimen> <dimen name="popup_maps_streetview_height">160dp</dimen> <dimen name="gallery_image_width">260dp</dimen> <dimen name="gallery_image_height">160dp</dimen> <dimen name="image_thumbnail_size">100dp</dimen> <dimen name="image_thumbnail_spacing">1dp</dimen> <dimen name="list_row_spacing">1dp</dimen> <dimen name="product_image_size">240dp</dimen> <dimen name="activity_horizontal_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen> <dimen name="nav_header_vertical_spacing">16dp</dimen> <dimen name="nav_header_height">160dp</dimen>你尝试过替换吗?
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)时;它不应该那样做了.