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

  • Home
  • SEARCH
  • 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 8992959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:05:05+00:00 2026-06-15T23:05:05+00:00

I have a screen with RelativeLayout in Android, with a TableLayout, and a TableRow,

  • 0

I have a screen with RelativeLayout in Android, with a TableLayout, and a TableRow, and then 6 widgets: 4 TextView’s, and 2 Buttons.

When I display it on a tablet size emulator, all the widgets are in. But when I move to a phone size emulator (5 inch), one and a half of the two buttons disappear to the right.

I was hoping that RelativeLayout will show all of them on screen. How can I achieve this?

My RelativeLayout is declared like this:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:paddingLeft="16dp"
  android:paddingRight="16dp" >

The TableLayout:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/cancelTable"
  android:layout_below="@+id/pageheader"
  android:layout_width="fill_parent"
android:layout_height="fill_parent" >

TableRow:

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="5dip" >

The TextView’s and Buttons are initiated in the Activity’s onCreate:

    table = (TableLayout) findViewById(R.id.cancelTable);
    table.removeAllViewsInLayout();

    TableRow tr=new TableRow(Edit.this);
    tr.removeAllViewsInLayout();
    int flag = 1;       
    if(flag == 1) {
        TextView b11=new TextView(Edit.this);
        b11.setText("Name");
        b11.setTextColor(Color.RED);
        b11.setTextSize(15);
        tr.addView(b11);

        TextView b4 = new TextView(Edit.this);
        b4.setPadding(10, 0, 0, 0);
        b4.setTextSize(15);
        b4.setText("Text");
        b4.setTextColor(Color.RED);
        tr.addView(b4);

        TextView b5=new TextView(Edit.this);
        b5.setPadding(10, 0, 0, 0);
        b5.setText("Number");
        b5.setTextColor(Color.RED);
        b5.setTextSize(15);
        tr.addView(b5);

        TextView b7=new TextView(Edit.this);
        b7.setPadding(10, 0, 0, 0);
        b7.setText("Time");
        b7.setTextColor(Color.RED);
        b7.setTextSize(15);
        tr.addView(b7);

        TextView b8=new TextView(Edit.this);
        b8.setPadding(10, 0, 0, 0);
        b8.setText("Delete");
        b8.setTextColor(Color.RED);
        b8.setTextSize(15);
        tr.addView(b8);

        TextView b9=new TextView(Edit.this);
        b9.setPadding(10, 0, 0, 0);
        b9.setText("Edit");
        b9.setTextColor(Color.RED);
        b9.setTextSize(15);
        tr.addView(b9);


        table.addView(tr);

        final View vline = new View(Edit.this);
        vline.setLayoutParams(new       
        TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, 2));
        vline.setBackgroundColor(Color.RED);
        table.addView(vline); 
        flag=0;
   }

    com.eyal.sms.db.SMS sms;        
    for(int i=0; i<allSched.size(); i++) {

        tr = new TableRow(Edit.this);
        tr.removeAllViewsInLayout();

        sms = allSched.get(i);

        TextView b = new TextView(Edit.this);
        String str = String.valueOf(sms.getToContact());
        b.setText(str != null ? str : "");
        b.setTextColor(Color.WHITE);
        b.setTextSize(15);
        tr.addView(b);

        TextView b1=new TextView(Edit.this);
        b1.setPadding(10, 0, 0, 0);
        b1.setTextSize(15);
        String str1 = sms.getText();
        if (str1.length() > 20) 
            str1 = str1.substring(0, 20); 

        b1.setText(str1);
        b1.setTextColor(Color.WHITE);
        tr.addView(b1);

        TextView b2 = new TextView(Edit.this);
        b2.setPadding(10, 0, 0, 0);
        String str2 = String.valueOf(sms.getToNumber());
        b2.setText(str2);
        b2.setTextColor(Color.WHITE);
        b2.setTextSize(15);
        tr.addView(b2);

        TextView b3 = new TextView(Edit.this);
        b3.setPadding(10, 0, 0, 0);
        String str3 = String.valueOf(sms.getTime());
        b3.setText(str3);
        b3.setTextColor(Color.WHITE);
        b3.setTextSize(15);
        tr.addView(b3);


        Button delete = new Button(Edit.this);
        delete.setText("Delete");            
        DeleteButtonListener dbl = new DeleteButtonListener();
        dbl.setSMS(sms);
        delete.setOnClickListener(dbl);            
        tr.addView(delete);

        Button edit = new Button(Edit.this);
        edit.setText("Edit");
        EditButtonListener ebl = new EditButtonListener();
        ebl.setSMS(sms);
        edit.setOnClickListener(ebl);
        tr.addView(edit);

        table.addView(tr);


        final View vline1 = new View(Edit.this);
        vline1.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, 1));
        vline1.setBackgroundColor(Color.WHITE);
        table.addView(vline1);  // add line below each row  

    }

What am I missing? Can RelativeLayout — or any other layout in Android — guarantee that all my widgets will be on the screen, or at least scrollable, in all sizes of hardware?

  • 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-15T23:05:06+00:00Added an answer on June 15, 2026 at 11:05 pm

    Try this it will wrap your TableLayout, and fixed your problem i hope

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:paddingLeft="16dp"
        android:paddingRight="16dp" >
    
        <HorizontalScrollView
            android:id="@+id/horizontalScrollView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal" >
    
                <TableLayout
                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/cancelTable"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_below="@+id/pageheader" >
    
                </TableLayout>
            </LinearLayout>
        </HorizontalScrollView>
    
    </RelativeLayout>
    

    [EDIT 1]

    import android.app.Activity;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.widget.Button;
    import android.widget.TableLayout;
    import android.widget.TableRow;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
        TableLayout table;
        TableRow tr;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            table = (TableLayout) findViewById(R.id.cancelTable);
            table.removeAllViewsInLayout();
            tr = new TableRow(MainActivity.this);
            int flag = 1;       
            if(flag == 1) {
                TextView b11=new TextView(MainActivity.this);
                b11.setText("Name");
                b11.setTextColor(Color.RED);
                b11.setTextSize(15);
                tr.addView(b11);
    
                TextView b4 = new TextView(MainActivity.this);
                b4.setPadding(10, 0, 0, 0);
                b4.setTextSize(15);
                b4.setText("Text");
                b4.setTextColor(Color.RED);
                tr.addView(b4);
    
                TextView b5=new TextView(MainActivity.this);
                b5.setPadding(10, 0, 0, 0);
                b5.setText("Number");
                b5.setTextColor(Color.RED);
                b5.setTextSize(15);
                tr.addView(b5);
    
                TextView b7=new TextView(MainActivity.this);
                b7.setPadding(10, 0, 0, 0);
                b7.setText("Time");
                b7.setTextColor(Color.RED);
                b7.setTextSize(15);
                tr.addView(b7);
    
                TextView b8=new TextView(MainActivity.this);
                b8.setPadding(10, 0, 0, 0);
                b8.setText("Delete");
                b8.setTextColor(Color.RED);
                b8.setTextSize(15);
                tr.addView(b8);
    
                TextView b9=new TextView(MainActivity.this);
                b9.setPadding(10, 0, 0, 0);
                b9.setText("Edit");
                b9.setTextColor(Color.RED);
                b9.setTextSize(15);
                tr.addView(b9);
    
    
                table.addView(tr);
    
                flag=0;
           }
    
            for(int i=0; i<30; i++) {
                tr = new TableRow(MainActivity.this);
    
                TextView b = new TextView(MainActivity.this);
                b.setText("TExt");
                b.setTextColor(Color.WHITE);
                b.setTextSize(15);
                tr.addView(b);
    
                TextView b1=new TextView(MainActivity.this);
                b1.setPadding(10, 0, 0, 0);
                b1.setTextSize(15);
                b1.setText("text2");
                b1.setTextColor(Color.WHITE);
                tr.addView(b1);
    
                TextView b2 = new TextView(MainActivity.this);
                b2.setPadding(10, 0, 0, 0);
                b2.setText("text3");
                b2.setTextColor(Color.WHITE);
                b2.setTextSize(15);
                tr.addView(b2);
    
                TextView b3 = new TextView(MainActivity.this);
                b3.setPadding(10, 0, 0, 0);
                b3.setText("text4");
                b3.setTextColor(Color.WHITE);
                b3.setTextSize(15);
                tr.addView(b3);
    
    
                Button delete = new Button(MainActivity.this);
                delete.setText("Delete");            
                tr.addView(delete);
    
                Button MainActivity = new Button(MainActivity.this);
                MainActivity.setText("MainActivity");            
                tr.addView(MainActivity);
    
                table.addView(tr);
    
            }
    
        }  
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have designed the screen using this relative layout. <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android
i have a screen with multiple little widgets (all with different divs around them).
I have added a LinearLayOut having some buttons My screen is RelativeLayOut it self
I have a simple screen created in xml, the parent layout is a relativelayout
i have a screen and it is i want the buttons to put under
i have a screen contains just two components 1-textView 2-button the textView starts from
I have an Android Activity with a RelativeLayout and I have implemented the following
I have set image in AbsoluteLayout but it'll not display in full screen on
I'm trying to create an android screen that has a TableLayout anchored to the
I'm working on android app, and I have the screen where the user can

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.