I don't need a solid line of drawings. I just need how to draw a line with mixed color or multi color in Android.
Asked
Active
Viewed 314 times
-2
-
draw a piece of line with one color, other peace - with other color. This way you will get multi color line. – Vladyslav Matviienko Jun 07 '17 at 05:34
-
can you show us image what you want exactly ? – Sushant Gosavi Jun 07 '17 at 05:44
-
we can do everything in android just clear what exactly you want so we will suggest you how to do this – Sushant Gosavi Jun 07 '17 at 05:45
-
I want to draw a line with any mixed color like rainbow, using onTouchEvent in android. – cheezee Jun 07 '17 at 05:53
-
did you want to change the color on selection of it ? – Sushant Gosavi Jun 07 '17 at 05:57
-
no, not change. When I first touch the screen, the color of line must be a mixed color. I can draw line with solid color, but I cannot draw line with mixed color. – cheezee Jun 07 '17 at 06:04
-
Go through this link https://stackoverflow.com/questions/3616676/how-to-draw-a-line-in-android You can change color and pass point from where to where you need x color. or this https://stackoverflow.com/questions/3616676/how-to-draw-a-line-in-android – Vindhya Pratap Singh Jun 07 '17 at 07:17
1 Answers
0
try this one
multicolor.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<gradient
android:type="linear"
android:centerX="44%"
android:startColor="#FF00ff00"
android:centerColor="#FFFF0000"
android:endColor="#FFffff00"
android:angle="90"/>
</shape>
line.xml
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/multicolor" />

Aniruddh Parihar
- 3,072
- 3
- 21
- 39
-
I want to know how to draw a line with onTouchEvent in java file, not the xml. – cheezee Jun 07 '17 at 05:48