微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 如何从ToggleButton中删除材质阴影?

今天我遇到了一个问题:

在我的自定义布局中,LinearLayout具有灰色背景,而ToggleButton位于此LinearLayout内的TextView之后.
切换按钮具有透明背景.
但在android Lollipop这里是不必要的影子.
我试过了elevation = 0dp属性.但这并没有解决我的问题.

当我设置api = 21时会发生这种情况

并且发生在旧的apis< 21 以下是示例布局:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="45dp"
    android:orientation="horizontal"
    android:background="@color/grey_light">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0123" />

    <ToggleButton
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:background="@android:color/transparent"
        android:button="@android:color/transparent" />
</LinearLayout>

如何删除这个阴影?

解决方法

尝试使用style =“@ android:style / Widget.Holo.Button.Borderless

将小部件更改为appcompat(或您正在使用的任何内容).

我用这个:

style="?android:attr/borderlessButtonStyle"

原文地址:https://www.jb51.cc/android/317838.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐