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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:04:50+00:00 2026-06-05T16:04:50+00:00

I have a dynamic size RelativeLayout containing TextView with a arbitrary text. Also i

  • 0

I have a dynamic size RelativeLayout containing TextView with a arbitrary text. Also i have fixed size TextView with timestamp. I want to place both RelativeLayout and TextView with timestamp in one line, side by side.

Like this:

What I want to get

What I’m really getting:

What I'm really getting

As you can see, layout with text just occupies the entire width.

XML:

    <RelativeLayout android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/news_list_element"
                android:layout_marginRight="5dip"
                android:layout_alignParentLeft="true"
                android:focusable="false"
                android:paddingRight="8dip"
                android:paddingLeft="17dip"
                android:paddingTop="4dip"
                android:paddingBottom="4dip">
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/news_list_text"
              android:background="@android:color/transparent"
              android:textColor="#000000"
              android:focusable="false"
              android:padding="3dip"
            />
</RelativeLayout>
<TextView android:id="@+id/messages_dialog_timestamp_in"
          android:background="#000000"
          android:text="12:05"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_toRightOf="@id/news_list_element"
          android:paddingBottom="9dip"
          android:paddingLeft="0dip"
          android:textColor="#8f9eac"
        />
  • 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-06-05T16:04:52+00:00Added an answer on June 5, 2026 at 4:04 pm

    Try this:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <TextView 
            android:layout_width="0dp" 
            android:layout_height="wrap_content" 
            android:id="@+id/news_list_text" 
            android:background="@android:color/transparent" 
            android:textColor="#000000" 
            android:focusable="false" 
            android:padding="3dip" 
            android:layout_weight="1"
            android:layout_gravity="left"
        /> 
        <TextView android:id="@+id/messages_dialog_timestamp_in" 
            android:background="#000000" 
            android:text="12:05" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:paddingBottom="9dip" 
            android:paddingLeft="0dip" 
            android:textColor="#8f9eac" 
            android:layout_gravity="right"
        /> 
    

    The android:layout_gravity="left" will make the message TextView start from the left edge of the parent.

    The android:layout_gravity="right" will put the timestamp Textview on the right edge of the parent.

    The android:layout_width="0dp" combined with the android:layout_weight="1" in the message TextView will cause it to expand to fill all remaining space after all other widgets are in place and have their required space set aside (so it won’t push the timestamp off the screen).

    This layout will be a little different from what you show as even with short messages the Textview area will expand to fill the available space and make the timestamps all appear in a vertical line on the right edge (which would look neater IMO).

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

Sidebar

Related Questions

Possible Duplicate: Auto-size dynamic text to fill fixed size container. Let's say i have
I have dynamic no of textviews and their size can also be dynamic, after
Possible Duplicate: Auto-size dynamic text to fill fixed size container Please take a look
I have dynamic text field that must be a fixed width and height. The
I have a dynamic listview with one text and one checkbox per line.when i
Is there anyway to have the validates_attachment_size except a dynamic file size limit? Here's
I have a <p> element I want to fix its position, but the text
hello everyone i have multiple dynamic edittext box.i want to give width to fill
I have the following dynamic finder: gl=GlobalList.find_by_list_id_and_global_id(2, 89) Basically, I just want to see
I have some dynamic content which covers up to 3 page and I want

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.