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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:42:48+00:00 2026-06-02T09:42:48+00:00

I am using the following layout and want to add textviews one below another

  • 0

I am using the following layout and want to add textviews one below another dynamically(depending on the data I want to display)

main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:id="@+id/contain"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >




    </LinearLayout>


</ScrollView>

So I tried this

public class Feeds extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Intent intent=getIntent();
        Bundle b=intent.getExtras();
      String s= b.getString("datapack");

      Log.w("String",s);
      String data[]=s.split("#");




String temp="";
      LinearLayout l=(LinearLayout)findViewById(R.id.contain);
      LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
              (LayoutParams.WRAP_CONTENT), (LayoutParams.WRAP_CONTENT));

      RelativeLayout relative = new RelativeLayout(getApplicationContext());
      relative.setLayoutParams(lp);


      for(int i=1;i<data.length;i++)
      {Log.w("i data",data[i]);
          temp=temp  + data[i] + ",";
          Log.w("tag",temp);
          if(i%5==0)
          {Log.w("data",temp);
              TextView tv = new TextView(getApplicationContext());
              tv.setLayoutParams(lp);
              tv.setId(i);
              tv.setText(temp);
              relative.addView(tv, lp);
              temp=null;

          }

      }
      l.addView(relative);




    }
}

I am using Scrollview for the first time so that is crating a bit of problem but the main problem is that the textviews in the relative layout overlap one another.How can I specify the gap between each view??

Overlapping

  • 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-02T09:42:57+00:00Added an answer on June 2, 2026 at 9:42 am

    I don’t see where you are defining the positions for each textview, ie layout_below, layout_toLeftOf… If no positions are defined the relative layout stacks each view in the upper left corner.

    Addition

    It seems digulino and I agree. I would like to add that you should be able to get the layout scheme you want with only a RelativeLayout inside a ScrollView, maybe a HorizontalScrollView too if you want horizontal scrolling with fling gesture support.

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

Sidebar

Related Questions

IMHO the following is the typical 3-column-layout using CSS. Without the surrounding #main-div it
I am facing the following problem: I want to add dynamically a mobile site
I want to place each character on new line. I am using following xml.
I'm using the following code to use a ListView in CustomAlertDialog Layout . public
I have the following graph using dot layout: digraph G { graph [rankdir=LR]; subgraph
Im using the following layout: http://matthewjamestaylor.com/blog/holy-grail-no-quirks-mode.htm This is working exacly like it it should
I have made following relative layout in an xml file lets say add_relative_layout.xml <?xml
Using the following table layout: TABLE Something ( SomethingId Name DateCreated IsObsolete ('Y','N') PRIMARY
In my Android application, I add a ListView element (for example) in the main.xml
I want to add programatically 4 children to dijit.layout.AccordionContainer . The script runs with

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.