shape中写好的虚线在TextView中无法显示

665 阅读1分钟

shape中的代码如下:

<shape xmlns:android="http://schemas.android.com/apk/res/android"    
   android:shape="line">    
<stroke        
   android:dashGap="10dp"        
   android:dashWidth="6dp"        
   android:width="1dp"        
   android:color="#D5D5D5" />    
<size 
   android:height="5dp" />
</shape>

解决方法:

在TextView中加入

android:layerType="software"

TextView代码如下:

<TextView    
   android:layout_width="match_parent"    
   android:layout_height="wrap_content"    
   android:layerType="software"    
   android:background="@drawable/home_cardview_dottedline"/>