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 6587261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:53:42+00:00 2026-05-25T16:53:42+00:00

In my LinearLayout the use of weight in Combination with Gravity causes to reverse

  • 0

In my LinearLayout the use of weight in Combination with Gravity causes to reverse the effect of weight. The Layout:

<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_weight="0.2">
    <TextView android:id="@+id/feedfragmentTitle" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_weight="8"/>
    <TextView android:id="@+id/feedfragmentDate" android:layout_height="wrap_content" android:gravity="right" android:layout_width="fill_parent" android:layout_weight="2"/>
</LinearLayout>

The given LinearLayout contains a Title, which should appromately take 80% of the Layout and an Date+Time with 20%. The Date+Time should have the Gravity of right. The layout i posted doesnt work unfortunately and if i play with the parameters weight, the result is the inversed one.

Is there another way to get the Results without swapping the weights ?

  • 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-25T16:53:43+00:00Added an answer on May 25, 2026 at 4:53 pm

    When you use the layout_weight property you need to make the appropriate height or width as 0dip

    try this

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="horizontal" android:layout_width="fill_parent" 
        android:layout_height="wrap_content">
        <TextView android:id="@+id/feedfragmentTitle" 
            android:layout_height="wrap_content" android:layout_width="0dip" 
            android:layout_weight="8" android:text="sdfdfsfsd"/>
        <TextView android:text="aass" android:id="@+id/feedfragmentDate" 
            android:layout_height="wrap_content" 
           android:gravity="right" android:layout_width="0dip" 
           android:layout_weight="2"/>
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this as part of my layout: <LinearLayout android:layout_width=fill_parent android:layout_height=0dip android:orientation=horizontal android:layout_weight=0.15> <TextView
I've got the following code: <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content > <EditText android:id=@+id/editText1 android:layout_width=0dp android:layout_height=150dp android:layout_weight=3
I have a code like this: ... <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:weightSum=10> <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content
I have next view hiererchy: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:paddingLeft=10dp android:paddingRight=10dp android:gravity=center> <LinearLayout android:layout_width=fill_parent
I use the following main.xml for my app. <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have this simple layout: <?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 >
I want to add linearlayout in table row and that linear layout will hold
Actually my code is: LinearLayout ll = new LinearLayout(this); ll.setId(i); ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)); ll.setPadding(0, 0,
I'm trying to use Java ( not XML ) to create a LinearLayout with
I'm trying to use a 9-patch drawable as the background of a LinearLayout. when

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.