gpt4 book ai didi

android - Spinner 图形错误 API 21

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:15:57 24 4
gpt4 key购买 nike

我在一个 fragment 中有一个微调器,它有一个非常烦人的图形故障。这仅发生在我的 API 21 的 Nexus 5 上。 enter image description here

我已尝试设置 spinner.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 但故障仍然存在。有什么想法吗?

最佳答案

我设法通过两种不同的方式解决了这个错误:

  1. 为微调器设置样式:

    <Spinner
    android:background="@drawable/background"
    android:id="@+id/spinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@android:style/Widget.Holo.Light.Spinner"/>

也许预定义样式中的背景颜色就足够了。如果不试试

  1. 创建一个带有圆角半径的可绘制形状:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="2dp" />
    <solid android:color="#00ff00" />
    </shape>

并将其设置为微调器的弹出背景

    <Spinner
android:background="@drawable/spinner_background"
android:id="@+id/date_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:popupBackground="@drawable/spinner_popup_background"/>

希望对您有所帮助!

关于android - Spinner 图形错误 API 21,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28013120/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com