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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:30:39+00:00 2026-06-01T19:30:39+00:00

I need your advice regarding my design and if you have a better idea

  • 0

I need your advice regarding my design and if you have a better idea (or you agree with me) that it is good. for some reason I have a feeling it is a “stone age programming style” but lets see.

Basically I have my xml relative layout. In the center (vertical and horizenatlly). I want to display “either” 3 buttons OR 3 texts depending on some user input. So what I did is the following:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clipChildren="false"
    android:clipToPadding="false" >

    <RelativeLayout android:id="@+id/Buttons"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" >
        <Button1 .../>
        <Button2 .../>
        <Button3 .../>
    </RelativeLayout>

    <RelativeLayout android:id="@+id/Texts"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" >
       <TextView1 .../>
       <TextView2.../>
       <TextView3.../>
    </RelativeLayout>

</RelativeLayout>

Depending on the user input in the code I set visibility to either Visible or Invisible

Is this alright? and if not what do you suggest?

  • 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-01T19:30:41+00:00Added an answer on June 1, 2026 at 7:30 pm

    In my opinion, what you have done may be primitive, but it is simple, which is good 🙂 But if you still want some options and make life complicated, then

    1. Put each of the blocks in a separate xml and use include.
    2. Make 2 views and then use ViewFlipper to flip them based on user requirements.

    But for the simple requirement that you have, I think u r doing fine.

    The include option would work something like this,

    layout_1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/Buttons"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" >
            <Button1 .../>
            <Button2 .../>
            <Button3 .../>
    </RelativeLayout>
    

    layout_2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/Texts"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true" >
           <TextView1 .../>
           <TextView2.../>
           <TextView3.../>
    </RelativeLayout>
    

    your main_layout.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mainLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clipChildren="false"
        android:clipToPadding="false" >
    
        <include layout="@layout/layout_1" />
        <include layout="@layout/layout_2" />   
    
    </RelativeLayout>
    

    The include helps you in making reusable layouts and also helps in keeping your xml files grow out of proportions, specially when you have complicated UIs.

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

Sidebar

Related Questions

Need some advice again please. This is regarding a single developer shop. I have
Good morning, experts I need your advice. Let's say we have user , profile
I need some advice regarding the handling of a Silverlight control that I need
Basically I need your advice my good stack friends :D For the last six
I am developing a WPF application, and I need your advice. I have to
I have no ideas how to do this, so I need your advice. I
I need your help in JAVA (with some sample code if possible) regarding to
I need your advice. We have an already working web resource management application, we
I'm trying to learn Domain Driven Design by example and I need your advice.
I have a little problem with my macrocode, and need your advice. Here my

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.