2016-12-29 19 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

は描画可能で、1つの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であっても、この行だけが役に立ちます。答えplsとして書く – Artem

関連する問題