Je veux dessiner des lignes pointillées horizontales et verticales dans Android en utilisant des formes.
je veux dessiner comme ça
Pour ligne horizontale
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<stroke
android:dashGap="6px"
android:dashWidth="6px"
android:color="#C7B299" />
</shape>
Pour ligne verticale
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line" >
<size
android:height="400dp"/>
<stroke
android:dashGap="6px"
android:dashWidth="6px"
android:color="#C7B299" />
</shape>
Mais la ligne pointillée verticale n'affiche pas ma sortie comme celle-ci
Comment tracer une ligne verticale.
Solution du problème
Si la vue a une largeur de 1dp, il ne suffit pas de faire pivoter votre ligne horizontale. La longueur de la ligne verticale sera de 1dp car elle est d'abord dessinée horizontalement, puis pivotée. Voici une astuce pour résoudre ce problème:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-300dp"
android:right="-300dp">
<rotate
android:drawable="@drawable/dash_line_divider_horizontal"
android:fromDegrees="90"
android:toDegrees="90"/>
</item>
</layer-list>
Aucun commentaire:
Enregistrer un commentaire