0

So this is part of the design that I'm working on it's flat as shown in the image. desired design Here is the implemented version there is this shadow that I cannot get rid of no matter what and it's not just in CardView component it's around all Views.

implemented version

Here is the code for the cardView

<android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/product_item_card"
        android:layout_gravity="center"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:layout_margin="@dimen/margin"
        android:layout_marginTop="@dimen/half_margin"
        android:layout_marginBottom="@dimen/half_margin"
        android:background="@color/color_foreground"
        card_view:cardCornerRadius="5dp"
        android:elevation="0dp"
        card_view:cardPreventCornerOverlap="false">

As shown I set the elevation to zero also tried setting LinearLayout elevation to zero and nothing changed

Here is another example including LinearLayout also notice it's around the EditText as well and even the button

enter image description here

here is code for EditText

    <EditText
        android:id="@+id/fragment_product_details_amount_et"
        android:layout_width="60dp"
        android:layout_height="30dp"
        android:layout_gravity="center"
        android:layout_marginLeft="10dp"
        android:background="@drawable/rounded_corners_with_border_grey"
        android:inputType="number"
        android:text="1"
        android:textAlignment="center" />

here is the drawable

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners
        android:radius="5dp"/>
    <solid android:color="@color/lightGrey"></solid> // #ADADAD
    <stroke android:width="1dp" android:color="@color/grey"/>
</shape>

Here is my styles.xml pretty much the defauls

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/color_primary</item>
        <item name="colorPrimaryDark">@color/color_primary_dark</item>
        <item name="colorAccent">@color/color_accent</item>
    </style>

    <style name="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

    <style name="FullscreenTheme" parent="AppTheme">
        <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
        <item name="android:windowActionBarOverlay">true</item>
        <item name="android:windowBackground">@null</item>
        <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
        <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
    </style>

    <style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
        <item name="android:background">@color/black_overlay</item>
    </style>

</resources>

Update: CardView and Button was fixed as advised by @ZeroOne. LinearLayout and EditText issue still persist. Added sample code.

Update: Added styles.xml

Update: issue fixed

Amgad Serry
  • 1,595
  • 2
  • 12
  • 20

1 Answers1

3

use card_view:cardElevation="0dp" instead of android:elevation="0dp"

and for the Button.. just add style="?android:attr/borderlessButtonStyle" to flat the button

ZeroOne
  • 8,996
  • 4
  • 27
  • 45