【问题标题】:android adds a shadow around all my views, How can i remove it?android在我所有的视图周围添加了一个阴影,我该如何删除它?
【发布时间】:2017-11-02 09:37:34
【问题描述】:

所以这是我正在处理的设计的一部分,如图所示。 这是实现的版本,无论如何我都无法摆脱这个阴影,而且它不仅在 CardView 组件中,而且在所有视图周围。

这是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">

如图所示,我将高度设置为零,也尝试将 LinearLayout 高度设置为零,但没有任何改变

这是另一个示例,包括 LinearLayout 也注意到它也在 EditText 周围,甚至是按钮

这里是 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" />

这是可绘制的

<?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>

这是我的 style.xml 几乎是默认设置

<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>

更新: CardView 和 Button 按照@ZeroOne 的建议进行了修复。 LinearLayout 和 EditText 问题仍然存在。 添加了示例代码。

更新: 添加了styles.xml

更新:问题已修复

【问题讨论】:

标签: android android-layout


【解决方案1】:

使用card_view:cardElevation="0dp" 代替android:elevation="0dp"

对于 Button.. 只需添加 style="?android:attr/borderlessButtonStyle" 即可平展按钮

【讨论】:

  • LinearLayout 和 EditText 怎么样
  • LinearLayout 和 Edittext 没有样式.. 请检查您的 styles.xml
  • 添加了 styles.xml 它没有任何关于边框或阴影的内容
猜你喜欢
  • 2016-08-31
  • 1970-01-01
  • 2018-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-28
  • 2015-07-29
相关资源
最近更新 更多