Vertical Line Separator with TextView

Welcome to "Android Super Nerds". Thanks for coming back to my site, I really appreciate that and if you guys are new to my Site please do check my previous articles as well.



So back to the topic title which states Vertical Line Separator with TextView".

Vertical Line Separator with TextView

Linear layout is the parent component which is used for most the Android UI Design. 

As discussed in our previous blog, depending on its orientation we choose, for its child UI component to be aligned either vertical or horizontal.

For example, if orientation under Linear layout is set as horizontal, any child inside the linear layout component will be displayed as horizontally to each other.

Drawing a vertical line

For drawing a vertical separator line between different views, we need to make some changes in layout XML files. 

Notes: View separator is achievable by the layout itself.

The complete code is given below 🠇
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:gravity="center"
android:text="Hello" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="@android:color/holo_green_light"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:gravity="center"
android:text="World!" />
</LinearLayout>


Code Understanding

To get the vertical line between two equal width text view, we need to add the empty view in between the text view.

A view is empty, so we need to set it layout_width with some static value and layout_height with matching parent height .i.e match_parent.

The parent view is the linear layout, so its orientation is set as horizontal and gravity is set as the center. Once the orientation and gravity are updated we can see that all the child is aligned center horizontally to each other. 

So the final outcome looks like this đŸ ‡



That's All Guys.

If you guys have any questions about any of the UI components, Please do Leave a comment below..!!

&&

If you like this article don’t forget to share it.
Till then "Happy Coding".



Comments

  1. Your new heart point might need to shift so far-off from the hazard that it’s now within the left rough. What issues here is the space between the middle of your new shot sample and the middle of your old shot sample. To perceive what causes snowmen in your scorecard, want to|you should|you have to} consideration to} these individual photographs. On common, 90-golfers make double or worse on 5 holes per spherical, compared to with} two holes 쏘걸 per spherical for 80-golfers.

    ReplyDelete
  2. That said, you can also make|you might make} bet365 your deposits via BTC, ETH, Litecoin, and Bitcoin Cash if you’re not keen to put your subsequent slots session on credit. They’ve also got one of many world’s busiest online poker rooms and online poker video games, with large multi-table tournaments rocking prize swimming pools that may contact a lot as} $1,000,000. Since iGaming operators are categorized as high-risk, a excessive chargeback price will ultimately impact an operator’s general revenue and harm their capacity merely accept|to just accept} bank card payments. Issuing banks may even blacklist you, not letting you pay using Visa or Mastercard, as an example.

    ReplyDelete

Post a Comment