0

I am new to android so I'm very sorry if this sounds like an easy question but I am trying to create the following line above the Text View where the arrow is pointing.

enter image description here

Is this called a View ? If so how do I place it? I know that this isn't just borders of the Text View because it doesn't go all the way to the edge.

Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
Mysterious_android
  • 598
  • 2
  • 9
  • 32
  • This line should be a ListView seperator line, see for example http://stackoverflow.com/questions/2372415/how-to-change-color-of-android-listview-separator-line – bnydev Sep 03 '16 at 06:11
  • The listview separator wont show above the first element, he has got to use a View – Aman Grover Sep 03 '16 at 06:12
  • Are you sure that "Smart Color Adjustments" is the first entry? It can be the second. It depends on the context which way is the correct one. If nicko_yuan has a ListView, using seperator lines will be the preferred way. If not, then using a View. – bnydev Sep 03 '16 at 07:53

4 Answers4

1

As you said, this element is named View. And we often use as horizontal line:

<View 
    android:layout_width="match_parent"
    android:layout_height="1dp"/>

Here is another post discuss about your problem: divider line

Community
  • 1
  • 1
hqt
  • 29,632
  • 51
  • 171
  • 250
0

Use this instead of Text View in your layout.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#818181"
    android:paddingTop="1px"
    android:paddingBottom="1px">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:id="@+id/name"
        android:ellipsize="end"
        android:maxLines="1"
        android:textColor="#ffffff"
        android:text="Text"
        android:background="#ffffff"
        android:gravity="center"/>

</LinearLayout>
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58
Sabish.M
  • 2,022
  • 16
  • 34
0
  1. Yes, its View.
  2. you can use like this.

    <View 
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#e3e3e3"/>
    
brahmy adigopula
  • 617
  • 3
  • 15
V-rund Puro-hit
  • 5,518
  • 9
  • 31
  • 50
0
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#000"/><!--This will draw a line of 1 dp and black color-->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="anything you want" />

</LinearLayout>
Aman Grover
  • 1,621
  • 1
  • 21
  • 41