gpt4 book ai didi

android - 当应用程序在真正的Android设备上运行时,虚线实际上不是虚线

转载 作者:IT老高 更新时间:2023-10-28 22:00:31 25 4
gpt4 key购买 nike

在我的应用程序中,我使用 XML 定义的垂直虚线。

<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="90"
android:toDegrees="90">
<shape

android:shape="line">
<stroke

android:width="1dp"
android:color="@color/light_gray"
android:dashWidth="2dp"
android:dashGap="4dp"
/>
</shape>

当我在 Android Studio 中挑剔我的布局时,该线被正确渲染为虚线,但当我在真实设备上运行应用程序时出现问题。这条线很结实,没有间隙。可能是什么问题呢?我尝试了许多不同的设备,包括运行最新 4.3 Android 的设备。它看起来到处都是一样的。

最佳答案

这很可能与硬件加速有关:GL 模式不支持虚线。

它记录在这里: https://code.google.com/p/android/issues/detail?id=29944

像这样在你的 AndroidManifest.xml 中关闭你的硬件加速:

android:hardwareAccelerated="false"

或:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 

有关如何使用第一个解决方案的更多信息: http://developer.android.com/guide/topics/graphics/hardware-accel.html

关于android - 当应用程序在真正的Android设备上运行时,虚线实际上不是虚线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18931679/

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