2016-12-29 99 views
2

我想用shape作虚线。形状虚线,短划线不起作用

这是我的XML:

<?xml version="1.0" encoding="utf-8"?> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="line"> 
      <stroke android:color="@color/grey_divider" 
       android:width="1dip" 
       android:dashWidth="5dip" 
       android:dashGap="13dip"/> 
     </shape> 
    </item> 
</selector> 

在我的设备我看到这一点: enter image description here 但我需要的东西是这样的:

enter image description here

如何解决呢?

回答

4

试试这个

请在绘制一个XML文件中。(例如dashed_line.xml)

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="line"> 

    <stroke 
     android:color="#C7B299" 
     android:dashWidth="10px" 
     android:dashGap="10px" 
     android:width="1dp"/> 
</shape> 

现在在布局中使用的XML文件。在一些视图

android:background="@drawable/dashed_line" 
+0

使用 –

+0

+0

android:layerType =“software” - 即使使用我的XML,只有这一行可以帮助我。作为答案请教 – Artem