1

how to fixed dash line in UI full of width? in my screen dash line are not properly fully fit with width of screen see image bellow. I used manually TextView for dash if mobile width is small is move to next line some dashes like below of if mobile width is thick is left some space form right side.

My screenshot

My Code is as bellow:

  <ScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/border5" >

            <ImageView
                android:id="@+id/test_button_image"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:paddingLeft="5dp"
                android:src="@drawable/iicon" >
            </ImageView>

            <TextView
                android:id="@+id/test_button_text2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/test_button_image"
                android:layout_toRightOf="@+id/test_button_image"
                android:paddingLeft="10dp"
                android:paddingTop="10dp"
                android:text="Description"
                android:textColor="#000000"
                android:textSize="15sp"
                android:textStyle="bold" >
            </TextView>

            <TextView
                android:id="@+id/test_button_text23"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/test_button_text2"
                android:layout_below="@+id/test_button_text2"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="-------------------------------------------------"
                android:textColor="#000000" >
            </TextView>

            <TextView
                android:id="@+id/description"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/test_button_text2"
                android:layout_below="@+id/test_button_text23"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text=" "
                android:textColor="#000000" >
            </TextView>
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/border5" >

            <ImageView
                android:id="@+id/test_button_image20"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:paddingLeft="5dp"
                android:src="@drawable/iicon" >
            </ImageView>

            <TextView
                android:id="@+id/test_button_text12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignTop="@+id/test_button_image20"
                android:layout_toRightOf="@+id/test_button_image20"
                android:paddingLeft="10dp"
                android:paddingTop="10dp"
                android:text="Contains"
                android:textColor="#000000"
                android:textSize="15sp"
                android:textStyle="bold" >
            </TextView>

            <TextView
                android:id="@+id/test_button_text5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/test_button_text12"
                android:layout_toRightOf="@+id/test_button_image20"
                android:paddingBottom="10dp"
                android:paddingLeft="10dp"
                android:text="---------------------------------------"
                android:textColor="#000000" >
            </TextView>

            <com.schoollunchapp.HorizontalListView
                android:id="@+id/listview2"
                android:layout_width="wrap_content"
                android:layout_height="150dp"
                android:layout_below="@+id/test_button_text5"
                android:background="#ffffff" />
        </RelativeLayout>
Hardik Joshi
  • 9,259
  • 11
  • 59
  • 110
user2686011
  • 59
  • 1
  • 7

2 Answers2

1

I tried to create doted lines but not sure its perfectly with your requirement.

drawable/dotted.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="line">

    <stroke
       android:color="#C7B299"
       android:dashWidth="10px"
       android:dashGap="10px" />
</shape>

view.xml:

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/dotted" /> 

For more understanding also refer this answer. Hope it helps.

Community
  • 1
  • 1
Hardik Joshi
  • 9,259
  • 11
  • 59
  • 110
0

this worked for me :)

drawable/dotted.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line">

    <stroke
        android:dashWidth="10dp"
        android:dashGap="9dp"
        android:width="3dp"
        android:color="#757575" />
</shape>

layout/my_activity.xml:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:src="@drawable/dotted" />
maslick
  • 1,712
  • 19
  • 32