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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:52:07+00:00 2026-05-30T17:52:07+00:00

I have a horizontal LinearLayout that’s programmatically filled with its children. I would like

  • 0

I have a horizontal LinearLayout that’s programmatically filled with its children. I would like to be able to switch to a right-to-left layout (i.e. child 0 is on the far right, child 1 to its left, etc.) . The thing is, I want the layout to switch from RtL to LtR and back dynamically, that’s why e.g. this question is irrelevant to my case.

There doesn’t seem to be any way to set it directly in the code, especially since gravity is for alignment, not ordering.

So far I see the following workarounds:

  • On the ordering switch, re-add the children in an inverted order (problem: very ugly and resource-consuming).
  • Implement a subclass of LinearLayout with an overridden onLayout() method (problem: lots of copy-pasting the Android source due to helper layout members having a restrictive visibility).
  • Replace the LinearLayout with another, e.g. a TableLayout or a RelativeLayout, and change the layout params of the children on switch (problem: still somewhat kludgey).

Any more direct solutions or better workarounds?

EDIT: to clarify, I’m creating the children practically once during the activity run-time, and I can store them in a helper array/collection at no complication to the code.

  • 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-30T17:52:09+00:00Added an answer on May 30, 2026 at 5:52 pm

    While re-creating the children might be resource-intensive, re-ordering shouldn’t be that bad. You can take the existing views using getChildAt and getChildCount and then put them back in using the addView override with an index.

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

Sidebar

Related Questions

I want that button(child) will have 25% of full width of horizontal LinearLayout (its
I have a ul list that I display as a horizontal menu. I'd like
I have a Custom ListView that contains a vertical LinearLayout of horizontal LinearLayouts for
lets assume i have a LinearLayout , horizontal that contains a TextView and afterward
Basically, I have a LinearLayout that holds a random amount of horizontal LinearLayouts, and
I have a horizontal LinearLayout, inside which I have 2 TextViews. Let's say that
Do you know any controls inherited from the ItemsControl that have horizontal orientation of
i have a that contains a HORIZONTAL menu. the menu consists of an unordered
I have a LinearLayout that contains sublayouts which essentially mimick a 3x2 grid. Each
I have a custom component that is a combination of LinearLayout + ImageViewx2 +

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.