I want to create below layout in XML. I am able to create circle but I don't know how to connect them by a horizontal line:
Asked
Active
Viewed 68 times
-7
-
Use Html to draw horizontal line – kgandroid Sep 09 '15 at 10:23
-
1Put a generic View in between the TextViews, with a fixed height of 1dp (or what you see fit). And as a background, use a color. – Phantômaxx Sep 09 '15 at 10:23
-
in Android XML how to use that? – user3154663 Sep 09 '15 at 10:23
-
1Draw a line like @FrankN.Stein said, refer this http://stackoverflow.com/questions/19115332/android-draw-a-horizontal-line-between-views – Emil Sep 09 '15 at 10:25
2 Answers
1
You can do it by using LinearLayout
<LinearLayout
.......
......>
<CircleView..../>
<View
android:layout_width="50dp"
android:layout_height="2dp"
android:background="@color/circle_color"/>
<CircleView..../>
<View
android:layout_width="50dp"
android:layout_height="2dp"
android:background="@color/circle_color"/>
<CircleView..../>
</LinearLayout>
N J
- 25,967
- 13
- 73
- 94
-
-
you can create circle drawable for normal and selected view take checkbox instead of CircleView apply selector to checkbox, sma you can do to line selector – N J Sep 09 '15 at 10:52
0
Generally these (step-by-step) indicators are implemented using different images loaded via single ImageView
. Just load the appropriate drawable
for a particular step. This way you need not worry about writing/arranging lot of UI widgets
in xml
.
I am attaching sample images for your reference:
Gagan
- 1,467
- 1
- 12
- 26
-
-
You surely can but you will have to write quite a lot views for that (5 views for a 3 step process) and arranging those horizontal connectors between the circular views will take some time. Moreover, if you choose to change the layout in future then it will be a complete rework. :) – Gagan Sep 09 '15 at 10:36