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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:14:20+00:00 2026-05-23T04:14:20+00:00

I created a custom view. In it, theres a line, a textview, another line.

  • 0

I created a custom view. In it, theres a line, a textview, another line. beneath the bottom line, i wanted to put a new horizontally oriented linearlayout. when i run it, this nested linearlayout doesnt seem to show up at all. Instead, i can see the test button right underneath the bottom line. what am i doing wrong?

    public class MyView extends LinearLayout   {

        public MyView(Context context, Question question) {
            super(context);



    //      this.setLayoutParams(params);
            this.setOrientation(VERTICAL);
            this.setBackgroundColor(Color.WHITE);
            LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 2);
            View topLine = new View(context);
            lineParams.setMargins(0, 15, 0, 0);
            topLine.setBackgroundColor(Color.argb(255, 0, 159, 218));
            topLine.setLayoutParams(lineParams);

            this.addView(topLine);

            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

            //Challenge Question
            TextView questionText = new TextView(context);
            questionText.setTextColor(Color.BLACK);
            questionText.setTextSize(14);
            questionText.setLayoutParams(params);
            questionText.setGravity(Gravity.CENTER_HORIZONTAL);
            questionText.setText(question.getQuestion());

            this.addView(questionText);

            View bottomLine = new View(context);
            bottomLine.setBackgroundColor(Color.argb(255, 0, 159, 218));
            bottomLine.setLayoutParams(lineParams);


            this.addView(bottomLine);

            LinearLayout innerLayout = new LinearLayout(context);
            LinearLayout.LayoutParams innerLayoutParams = new LinearLayout.LayoutParams(300, LayoutParams.WRAP_CONTENT);
            innerLayout.setLayoutParams(innerLayoutParams);
            innerLayout.setBackgroundColor(Color.RED);
            innerLayout.setOrientation(HORIZONTAL);


            //TableLayout for the multiple choices  
            TableLayout tableLayout = new TableLayout(context);
            LayoutParams tableLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //      tableLayoutParams.weight = .8f;
            tableLayout.setBackgroundColor(Color.RED);
            tableLayout.setLayoutParams(tableLayoutParams);


            innerLayout.addView(tableLayout);
            this.addView(innerLayout);

            Button button = new Button(context);
            button.setLayoutParams(params);
            button.setText("testing 123");
            this.addView(button);
}

Note that I pasted the code without all the stuff that I added to the tablelayout. I probably should have pasted that too. But it didn’t work when I did that either. but either way, if i set the nested linearlayout to 300 width and set a background color of red to it, i should at least see it, no?

  • 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-23T04:14:21+00:00Added an answer on May 23, 2026 at 4:14 am

    Think about what the height of the inner layout should be. Right now it is wrap_content and contains a TableLayout (with no rows) with its height also set to wrap_content. There doesn’t seem to be anything in that inner layout giving it a height dimension, so that may be why it is not being displayed.

    Trying the following will make your layout visible:

        LinearLayout.LayoutParams innerLayoutParams = new LinearLayout.LayoutParams(300, 300);
    

    More usefully, you can try adding something with a real width/height to the TableLayout.

    Also consider writing your layout in XML to better separate your application logic and the presentation.

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

Sidebar

Related Questions

I've created a custom view class and right now just want to draw an
when i try to animate custom View (created in java code), there is no
I have created one custom view that contains the horizontalscrollview. Now when i changes
I created a custom view in IB for a picker row. The row has
I created a custom View Round button which consists of an image and some
VS2010 Ultimate, ASP.NET MVC 3 w/Razor. I've created a custom view engine in my
I'm using drupal 6 and view 2 - I've created a custom filter for
I have created a custom View (let's call it MyView ) which basically just
I have created a custom Base Adapter class, to populate a list view with
I create a custom right view as follows: // Build the Segmented Control NSArray

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.