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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:43:37+00:00 2026-05-27T21:43:37+00:00

I tried private void addSnapPictureRow(TableLayout table, Bitmap bitmap) { /* * 1st row =

  • 0

I tried

 private void addSnapPictureRow(TableLayout table, Bitmap bitmap) {
        /*
         * 1st row = TextView (Check In)
         */
        TableRow row = new TableRow(this);  
        row.setGravity(Gravity.CENTER_HORIZONTAL);
        // add text
        TextView text = new TextView(this);
        text.setText("Snap Picture");
        TableRow.LayoutParams textLayoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
        textLayoutParams.setMargins(100, 0, 0, 0);
        row.addView(text, textLayoutParams);

        // add picture
        ImageView picture = new ImageView(this);
        picture.setImageResource(R.drawable.adium);
        row.addView(picture);

        /*
         * 2nd row = View (separator)
         */
        TableRow separator = new TableRow(this);
        View line = new View(this);
        TableRow.LayoutParams separatorLayoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, 1);
        separatorLayoutParams.setMargins(100, 0, 0, 0);
        line.setBackgroundColor(Color.BLUE);
        separator.addView(line, separatorLayoutParams);

        // add row to table
        table.addView(row);
        // add a separator
        table.addView(separator);
    }

But the picture never showed. If I change the gravity to CENTER_HORIZONTAL, then it shows only a small part of the picture.

enter image description here

When create table with xml, I thought it automatically aligned horizontally. I can’t understand how TableRow layout works. Could anyone shed me some lights on this?

  • 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-27T21:43:38+00:00Added an answer on May 27, 2026 at 9:43 pm

    Adding an extra LinearLayout for each row solved my problem ;). The algignment of the previous row cause the picture go out of screen.

    private void addSnapPictureRow(TableLayout table, Bitmap bitmap) {
            /*
             * 1st row = TextView (Check In)
             */
            TableRow row = new TableRow(this);  
            LinearLayout outerLayout = new LinearLayout(this);
            // add text
            TextView text = new TextView(this);
            text.setText("Snap Picture");
            LinearLayout.LayoutParams textLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            textLayoutParams.setMargins(100, 0, 0, 0);
    
            // add picture
            ImageView picture = new ImageView(this);
            LinearLayout.LayoutParams pictureLayoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            picture.setImageResource(R.drawable.adium);
            pictureLayoutParams.setMargins(20, 0, 0, 0);
    
            outerLayout.addView(text, textLayoutParams);
            outerLayout.addView(picture, pictureLayoutParams);
            row.addView(outerLayout);
    
            /*
             * 2nd row = View (separator)
             */
            TableRow separator = new TableRow(this);
            View line = new View(this);
            TableRow.LayoutParams separatorLayoutParams = new TableRow.LayoutParams(400, 1);
            separatorLayoutParams.setMargins(100, 0, 0, 0);
            line.setBackgroundColor(Color.BLUE);
            separator.addView(line, separatorLayoutParams);
    
            // add row to table
            table.addView(row);
            // add a separator
            table.addView(separator);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use this: private void CreateDevice() { _playbackDevice = new WaveOut(); _playbackDevice.PlaybackStopped
I tried this private void botaoConfIOMouseClicked(java.awt.event.MouseEvent evt) { ConfigurarIO popup = new ConfigurarIO(); popup.setVisible(true);
i have a problem, i tried this code : private void button1_Click(object sender, RoutedEventArgs
I tried with no success: webBrowser1.Document.ExecCommand(alert('Hello World!'), true, null); also tried: private void webBrowser1_DocumentCompleted(object
Using: private void play() { VideoView v = (VideoView) findViewById(R.id.videoView); MediaPlayer mp = MediaPlayer.create(this,
I have a C# .NET 3.5 Windows Form program with this method: private void
I have this small piece of code. private void Application_Startup(object sender, StartupEventArgs e) {
System.Timers.Timer timer = new System.Timers.Timer(); private void button1_Click(object sender, EventArgs e) { timer.Elapsed +=
This is how I populate my DataGridView in the form load event: private void
i want to play a mp4 video. so i tried below method private void

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.