Create divider View not display well in android


Keywords:android 


Question: 

I am creating one Layout and in that I am putting divider via View. But Both Divider is not looking same. which have all property same.

Take a close look at screenshot :

enter image description here

The First one looked well as I want. But the second one is thin as you can close look.

Code :

            <TextView
                android:id="@+id/txt_security_currentRole"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingBottom="@dimen/normal_margin8"
                android:text="@string/security_current_role"
                android:textColor="#DE000000"
                android:fontFamily="sans-serif"
                android:textSize="@dimen/textsize14" />
            <View
                android:id="@+id/view_currentRole"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@+id/txt_security_currentRole"
                android:background="#61000000" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/view_currentRole"
                android:layout_marginLeft="@dimen/normal_margin8"
                android:paddingBottom="@dimen/normal_margin8"
                android:paddingTop="@dimen/normal_margin5"
                android:text="@string/security_user"
                android:textColor="#8A000000"
                android:fontFamily="sans-serif"
                android:textSize="@dimen/textsize14" />
            <TextView
                android:id="@+id/txt_upgraderole"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/view_currentRole"
                android:paddingTop="@dimen/normal_margin8"
                android:text="@string/security_upgrade_role"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/textsize14"
                android:textStyle="italic"
                android:fontFamily="sans-serif" />
            <TextView
                android:id="@+id/txt_viewpassword"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/txt_upgraderole"
                android:paddingBottom="@dimen/normal_margin8"
                android:text="@string/password"
                android:textColor="#DE000000"
                android:fontFamily="sans-serif"
                android:textSize="@dimen/textsize14" />
            <View
                android:id="@+id/view_password"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_below="@+id/txt_viewpassword"
                android:background="#61000000" />

If any one know what about that it can tell me.

Any Help be Highly Appreciated.


4 Answers: 

You can create a separate layout with the view you want and include it in the places where ever you need...I think this solution would help you...

 

I am agree with @Ironman that Textview is for displaying Text. You can check this:

<View
    android:layout_width="match_parent"
    android:layout_height="2dp"
    android:background="?android:attr/listDivider"/>
 

Try using Textview instead of View. Using textview gives same divider as view.

<TextView
    android:id="@+id/txt_security_currentRole"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingBottom="@dimen/normal_margin8"
    android:text="@string/security_current_role"
    android:textColor="#DE000000"
    android:fontFamily="sans-serif"
    android:textSize="@dimen/textsize14" />
<TextView
    android:id="@+id/view_currentRole"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/txt_security_currentRole"
    android:background="#61000000" />
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/view_currentRole"
    android:layout_marginLeft="@dimen/normal_margin8"
    android:paddingBottom="@dimen/normal_margin8"
    android:paddingTop="@dimen/normal_margin5"
    android:text="@string/security_user"
    android:textColor="#8A000000"
    android:fontFamily="sans-serif"
    android:textSize="@dimen/textsize14" />
<TextView
    android:id="@+id/txt_upgraderole"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/view_currentRole"
    android:paddingTop="@dimen/normal_margin8"
    android:text="@string/security_upgrade_role"
    android:textColor="@color/colorPrimary"
    android:textSize="@dimen/textsize14"
    android:textStyle="italic"
    android:fontFamily="sans-serif" />
<TextView
    android:id="@+id/txt_viewpassword"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/txt_upgraderole"
    android:paddingBottom="@dimen/normal_margin8"
    android:text="@string/password"
    android:textColor="#DE000000"
    android:fontFamily="sans-serif"
    android:textSize="@dimen/textsize14" />
<TextView
    android:id="@+id/view_password"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:layout_below="@+id/txt_viewpassword"
    android:background="#61000000" />

I've just replaced <View> by <Textview>

 

After lots of try like

1. Clean the Project and Rebuild it

2. Restart The Studio.

3. Restart the whole System

nothing is work well.

Finally Uninstall the App and reinstall is work for me.