Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – Display 2 or more textviews in one row

Posted on November 11, 2022 By

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>

enter image description here

Comments

Comment posted by Dushyant Singh

do you want the second textview towards the right end or just next to first one?

READ  [FIXED] java - in php, how to retrieve an objects array sent by retrofit
Powered by Inline Related Posts
Android Tags:android, java, textview

Post navigation

Previous Post: [FIXED] android – Build not succed in flutter
Next Post: [FIXED] kotlin – Opening the application from the results google.com, always directs to the home page of WebView Android

Related Posts

[FIXED] java – androidx.constraintlayout.widget.Group not working with setTranslationY Android
[FIXED] java – How to change or modify pitch of audio file (music etc like .mp3 file)using FFMPEG? Android
[FIXED] java – Simple android studio app is crashing when i run it. it have no errors Android
[FIXED] android – Pass JSON to Firebase Dynamic Link Android
[FIXED] c# – Unity Can not Build because of IL2CPP Problem Unity 2019.2.17f1 Android
[FIXED] android – How to get a value from Kotlin AsyncTask Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme