Reputation: 618
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.
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.
Upvotes: 0
Views: 71
Reputation: 2060
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>
Upvotes: 0
Reputation: 5534
you can use like this.
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#e3e3e3"/>
Upvotes: 0
Reputation: 30266
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
Upvotes: 1
Reputation: 1641
<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>
Upvotes: 0