zoukankan      html  css  js  c++  java
  • 【转】Android Shape绘制虚线在手机端查看是实线的问题

    Android share绘制虚线在手机上显示实线问题

    给控件添加Drawableleft等图片后,单独给图片设置动画效果,参考文章:

    http://blog.csdn.net/langzxz/article/details/47069235

    效果未测试。

    原文博客链接:http://wv1124.iteye.com/blog/2187204

    博客分类: 
     

    可以说这是一个Bug, 据说在4.0以上机器会出现,我测试是android 4.4.2

    Xml代码  收藏代码
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
    3.     android:shape="line" >  
    4.   
    5.     <stroke  
    6.         android:dashGap="3dp"  
    7.         android:dashWidth="8dp"  
    8.         android:width="1dp"  
    9.         android:color="#999999" />  
    10.   
    11.     <size android:height="1dp" />  
    12.   
    13. </shape>  

    layout中引用:

    Xml代码  收藏代码
    1. <View  
    2.         android:layout_width="match_parent"  
    3.         android:layout_height="3dp"  
    4.         android:layout_marginBottom="5dp"  
    5.         android:layout_marginTop="5dp"  
    6.         android:background="@drawable/left_menu_dash_line" />  

     在4.4.2上显示实线。

    解决:

    Xml代码  收藏代码
    1. <View  
    2.         android:layerType="software"  
    3.         android:layout_width="match_parent"  
    4.         android:layout_height="3dp"  
    5.         android:layout_marginBottom="5dp"  
    6.         android:layout_marginTop="5dp"  
    7.         android:background="@drawable/left_menu_dash_line" />  

    重点:

    Xml代码  收藏代码
    1. android:layerType="software"  

    也可以:

    Java代码  收藏代码
    1. <activity android:name=".TestActivity" android:label="Test"  
    2.             android:hardwareAccelerated="false">  

     重点关闭硬件加速:

    Java代码  收藏代码
    1. android:hardwareAccelerated="false"  
    divider_under_pic.setLayerType(View.LAYER_TYPE_SOFTWARE,null);

     代码中使用setLayerType设置。

    参考:

    http://developer.android.com/guide/topics/graphics/hardware-accel.html

  • 相关阅读:
    中债登、银行间市场、上清所… 这些机构你能分清几个?
    期货界的四大天王
    心理学的几个现象
    西方金融交易员揭露行业潜规则
    瑞银保住欧股交易经纪龙头宝座 算法交易傲视同业
    【Python】 zabbixAPI的包装pyzabbix
    【Python】 日志管理logging
    【Python】 子进程创建与使用subprocess
    【Python】 配置解析ConfigParser & 命令行参数解析optparser
    【Python】 SSH连接的paramiko
  • 原文地址:https://www.cnblogs.com/liyanli-mu640065/p/7256899.html
Copyright © 2011-2022 走看看