Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7414577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:07:40+00:00 2026-05-29T07:07:40+00:00

I have an activity designed to get customer information. First line gets name, 2nd

  • 0

I have an activity designed to get customer information. First line gets name, 2nd line street address, third line is city, state and zip. I can achieve what I want using a RelativeLayout and by using android:layout_below and android:layout_toRightOf, but then i have to specifically indicate a width for my views. That width may look odd as the user reorients or switches between older and newer versions of android where everything is sized differently. I want to utilize the weight feature of a LinearLayout, but everything just comes up all on one line. How do I insert a line break to create rows of views within a LinearLayout?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/custLabel"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_width="0dip"  
android:text="Name"/>
<EditText
android:id="@+id/customer"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:layout_width="0dip"/>
<TextView
android:id="@+id/addressLabel"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_width="0dip"
android:text="Address"/>
<EditText
android:id="@+id/address"
android:layout_height="wrap_content"
android:layout_weight=".75"
android:layout_width="0dip"/>
<TextView
android:id="@+id/cityLabel"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:layout_width="0dip"
android:text="City"/>
<EditText
android:id="@+id/city"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_width="0dip"/>
<TextView
android:id="@+id/stateLabel"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:layout_width="0dip"
android:text="State"/>
<EditText
android:id="@+id/state"
android:layout_height="wrap_content"
android:layout_weight=".20"
android:layout_width="0dip"/>
<TextView
android:id="@+id/zipLabel"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:layout_width="0dip"
android:text="Zip"/>
<EditText
android:id="@+id/zip"
android:layout_height="wrap_content"
android:layout_weight=".25"
android:layout_width="0dip"/>
</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:07:41+00:00Added an answer on May 29, 2026 at 7:07 am

    You must use nested LinearLayout‘s to do this. I think something like this

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
            <TextView
                android:id="@+id/custLabel"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".25"
                android:text="Name" />
    
            <EditText
                android:id="@+id/customer"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".75" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
            <TextView
                android:id="@+id/addressLabel"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".25"
                android:text="Address" />
    
            <EditText
                android:id="@+id/address"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".75" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
    
            <TextView
                android:id="@+id/cityLabel"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".1"
                android:text="City" />
    
            <EditText
                android:id="@+id/city"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".25" />
    
            <TextView
                android:id="@+id/stateLabel"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".1"
                android:text="State" />
    
            <EditText
                android:id="@+id/state"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".20" />
    
            <TextView
                android:id="@+id/zipLabel"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".1"
                android:text="Zip" />
    
            <EditText
                android:id="@+id/zip"
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight=".20" />
        </LinearLayout>
    </LinearLayout>
    

    should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed an activity that its orientation is landscape. Also I have designed
Hey I designed a help activity and I have kind of parents (groupItems) which
In my app I've designed it to have a Service that gets data constantly
I have designed an activity in which there is a listView. I want that
I have Activity A with android:launchMode=singleTop in the manifest. If I go to Activity
I have Activity with ListView inside it and in the onCreate method of the
I have an activity that has a TabHost containing a set of TabSpecs each
I have an Activity in Android, with two elements: EditText ListView When my Activity
I have an activity that contains several user editable items (an EditText field, RatingBar,
I have an activity which shows some List entries. When I click on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.