今天,我遇到了一个问题:
在我的自定义布局中,此LinearLayout内的TextView之后有灰色背景的LinearLayout和ToggleButton。切换按钮具有透明背景。但是在Android Lollipop中,这里是不必要的阴影。我尝试过levation = 0dp属性。但这并没有解决我的问题。
当我设置api = 21时会发生这种情况
并在<21的较旧api上发生这种情况
这是示例布局:
<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"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句