2016-09-21 5 views
-4

私はここで指定された答えをいくつか試しましたが、How do I make a dotted/dashed line in Android?xmlを使って太い破線を描くにはどうすればいいですか?

ですが、線はすべて細いです。

私に必要なものは、10倍の厚さのものです。正解から

コード結果を読んでくれてありがとう:

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.tester.MainActivity"> 

    <ImageView 
    android:layout_width="match_parent" 
    android:layout_height="20dp" 
    android:src="@drawable/dotted" 
    android:layerType="software"/> 
</RelativeLayout> 

dotted.xml

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="line" > 
    <stroke 
    android:dashGap="10px" 
    android:dashWidth="10px" 
    android:width="10dp" 
    android:color="@android:color/black" 
    /> 
</shape> 

Thick dotted line

+0

このような愚かな質問! – Piyush

+0

@Piyush、 '愚かな'部分について詳述するためのケア? –

答えて

2

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="10dp"/> 
    </shape> 
+0

これは役に立ちますか? @短答 –

+0

あなたはどのような形を定義しましたか?あなたは完全なXMLを投稿できますか? –

関連する問題