Dotted line is actually not dotted when app is running on real Android device

后端 未结 3 1892
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 16:40

in my app I use XML defined vertical dotted line.




        
相关标签:
3条回答
  • 2020-12-15 16:47

    I found a same solution but in View attributes (xml):

            <View
            android:layout_width="wrap_content"
            android:layout_height="4dp"
            ...
            android:layerType="software"/>
    

    I suppose it's a View level as said above. Other variants for attribute ("none" and of course "hardware") didn't work for me.

    0 讨论(0)
  • 2020-12-15 16:48

    Controlling Hardware Acceleration

    You can control hardware acceleration at the following levels:

    • Application

    • Activity

    • Window

    • View

    Application level

    <application android:hardwareAccelerated="true" ...>
    

    Activity level

    <application android:hardwareAccelerated="true">
        <activity ... />
        <activity android:hardwareAccelerated="false" />
    </application>
    

    Window level

    getWindow().setFlags(
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
        WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
    

    View level

    myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    

    Reference

    0 讨论(0)
  • 2020-12-15 16:58

    This is most likely related to hardware acceleration: Dashed lines are not supported in GL mode.

    Its documented here: https://code.google.com/p/android/issues/detail?id=29944

    Turn off your HW-acceleration in your AndroidManifest.xml like this:

    android:hardwareAccelerated="false"
    

    or:

    myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 
    

    For more information how to use first solution: http://developer.android.com/guide/topics/graphics/hardware-accel.html

    0 讨论(0)
提交回复
热议问题