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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:04:37+00:00 2026-06-04T20:04:37+00:00

I have an RelativeLayout and I would like to insert some textViews. Here is

  • 0

I have an RelativeLayout and I would like to insert some textViews.

Here is the code:

 <RelativeLayout
    android:id="@+id/JournalSearchListView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:minHeight="30dp"
    android:layout_below="@+id/JournalsSearchTextView"
    android:orientation="vertical" 
    android:cacheColorHint="#00000000">

    <ProgressBar
        android:id="@+id/JournalSearchProgressBar"
        style="?android:attr/progressBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

</RelativeLayout>

And how I am doing this programmatically:

RelativeLayout journals = (RelativeLayout) findViewById(R.id.JournalSearchListView);
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
for (int i=0;i< authorNames.size();i++) {
    TextView tv = new TextView(this);
    tv.setId(i); 
    tv.setText(authorNames.get(i));
    tv.setTextColor(Color.BLACK);
    Integer a = tv.hashCode();
    map.put(a,authorNames.get(i));
    params1.addRule(RelativeLayout.BELOW, tv.getId());
    journals.addView(tv, params1);
    tv.setOnClickListener(new OnClickListener() {
         public void onClick(View v) {
             System.out.println("Clicked "+ map.get(v.hashCode()) );    
         }
    });   
}

But the problem is that each textView is in the same position as the others.

  • 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-04T20:04:38+00:00Added an answer on June 4, 2026 at 8:04 pm

    params1.addRule(RelativeLayout.BELOW, tv.getId());

    You are setting it to be below itself?
    If you want them below eachother do it this way:

    RelativeLayout journals = (RelativeLayout);
    findViewById(R.id.JournalSearchListView);
    LinearLayout lL = new LinearLayout(context);
    lL.setOrientation(LinearLayout.VERTICAL);
    
    for (int i=0;i< authorNames.size();i++) {
        TextView tv = new TextView(this);
        tv.setId(i); 
        tv.setText(authorNames.get(i));
        tv.setTextColor(Color.BLACK);
        Integer a = tv.hashCode();
        map.put(a,authorNames.get(i));
    
        if(i!=0){
            params1.addRule(RelativeLayout.BELOW, i-1);
        }
    
        tv.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                System.out.println("Clicked "+ map.get(v.hashCode()) ); 
            }
        });
    
        lL.addView(tv);   
    
    }
    
    journals.addview(lL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a layout defined in XML. It contains also: <RelativeLayout android:id=@+id/item android:layout_width=fill_parent android:layout_height=wrap_content
I have the following layout: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=fill_parent android:background=@drawable/aussie_bg_big > <ImageView android:id=@+id/titleImage android:layout_width=wrap_content
Here's a layout: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical> <RelativeLayout android:id=@+id/first_tv_container android:layout_width=fill_parent android:layout_height=wrap_content android:focusable=true android:background=@android:drawable/list_selector_background>
I have the following ToggleButton in xml: <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=46dp android:gravity=center > <ToggleButton
I have this ImageView block inside a Relative layout: <ImageView android:layout_width=wrap_content android:layout_height=wrap_content android:layout_alignParentBottom=true android:layout_marginBottom=50dip
I have EditText in my XML as <!-- Inside RelativeLayout --> <EditText android:id=@+id/edtEmail android:layout_width=match_parent
Is it possible to have overlapping views in Android? I would like to have
I create button in xml file like this: <Button android:id=@+id/call_button android:layout_width=match_parent android:layout_height=0dp android:layout_marginTop=30dp android:background=@drawable/button
I have a RelativeLayout that holds a set of views and i would like
I have a RelativeLayout with one child as <include another.xml> like this root.xml :

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.