Solution 1 :
<?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="match_parent"
tools_context=".MainActivity"
android_orientation="vertical"
android_background="@drawable/background"
android_weightSum="1">
<LinearLayout
android_layout_width="match_parent"
android_layout_height="wrap_content"
android_orientation="horizontal"
android_weightSum="2">
<TextView
android_layout_width="0dp"
android_layout_height="28dp"
android_layout_gravity="right"
android_layout_weight="1"
android_text="Sign in"
android_textColor="#7041EE"
android_textSize="20dp" />
<TextView
android_id="@+id/nwah"
android_layout_width="0dp"
android_layout_height="28dp"
android_layout_weight="1"
android_layout_gravity="left"
android_text="New around here?"
android_textColor="#ACACAC"
android_textSize="20dp" />
</LinearLayout>
</LinearLayout>
Solution 2 :
You can add another view for textView
<LinearLayout // vertical
<LinearLayout // hotizontal
<TextView/>
<TextView/>
<LinearLayout/>
<LinearLayout/>
or you can use Constraint layout
Problem :
I saw some same questions, but
I’m using android:orientation="vertical"
so I can’t use orientation as horizontal.
How can I display 2 or more textviews on 1 row?
(Sorry for my english skills)
<?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="match_parent"
tools_context=".MainActivity"
android_orientation="vertical"
android_background="@drawable/background"
android_weightSum="1">
<TextView
android_layout_width="62dp"
android_layout_height="28dp"
android_layout_gravity="right"
android_text="Sign in"
android_textColor="#7041EE"
android_textSize="20dp" />
<TextView
android_id="@+id/nwah"
android_layout_width="162dp"
android_layout_height="28dp"
android_layout_gravity="left"
android_text="New around here?"
android_textColor="#ACACAC"
android_textSize="20dp" />
</LinearLayout>
Comments
Comment posted by Dushyant Singh
do you want the second textview towards the right end or just next to first one?