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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:15:58+00:00 2026-06-12T21:15:58+00:00

I have a TableLayout consisting of some buttons. I want to draw a rectangle

  • 0

I have a TableLayout consisting of some buttons. I want to draw a rectangle around the TableLayout. I am not sure how this could be done. From my research, I found that I would need to extend a View and use the onDraw event of this view. But, the point I am confused with is “How is it possible to include the TableLayout within the View”?

Thanks in advance for your answers.

My sample code is

<?xml version="1.0" encoding="utf-8"?>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:id="@+id/numkeypad"
         android:orientation="vertical"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:stretchColumns="*"
         android:layout_gravity="bottom"
         android:visibility="visible"
         android:background="@color/contents_text"
    >
<TableRow>
    <LinearLayout android:layout_height="wrap_content"
                  android:layout_width="0dp"
                  android:background="#404040"
                  android:layout_span="2">
        <Button android:id="@+id/Test1"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:textColor="#000000"
                android:text="Test1"
                android:textSize="20dp"
                android:textStyle="bold"
                >
        </Button>
        <Button android:id="@+id/Test2"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:textColor="#000000"
                android:text="Test2"
                android:textSize="20dp"
                android:textStyle="bold"
                >
        </Button>
    </LinearLayout>
</TableRow>
<TableRow>
    <LinearLayout android:layout_height="wrap_content"
                  android:layout_width="0dp"
                  android:background="#404040"
                  android:layout_span="2">
        <Button android:id="@+id/Test11"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:textColor="#000000"
                android:text="Test11"
                android:textSize="20dp"
                android:textStyle="bold"
                >
        </Button>
        <Button android:id="@+id/Test22"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content"
                android:layout_weight="1"
                android:textColor="#000000"
                android:text="Test22"
                android:textSize="20dp"
                android:textStyle="bold"
                >
        </Button>
    </LinearLayout>
</TableRow>

</TableLayout>

And the output I have is

enter image description here

And what I want is something like

enter image description here

  • 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-12T21:16:00+00:00Added an answer on June 12, 2026 at 9:16 pm

    You can extend FrameLayout to draw the rectangle according to it’s dimensions in the onDraw() method (after calling super.onDraw() of course)
    Say you extended class is com.example.MyFrameLayout.

    Then you can declare the following layout:

    <?xml version="1.0" encoding="utf-8"?>
    <com.example.MyFrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    
        <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/numkeypad"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:stretchColumns="*"
            android:layout_gravity="bottom"
            android:visibility="visible"
            android:background="@color/contents_text">
    
            ...
        </TableLayout>
    </com.example.MyFrameLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TableLayout in a HorizontalScrollView and I put this HorizontalScrollView and some
(Android 3.2) I have a TableLayout with 9 buttons. I want to know when
I have list of products which have EditText in TableLayout . I want Keyboard
I have a List of TableLayout's that are each generated from data in my
I have a TableLayout with a lot of buttons in each TableRow. In the
I have a cusom view derived from TableLayout, and I need to declare String
I have tablelayout inside linearlayout but it shows me this warning message This TableLayout
Some Background I have a TableLayout with 9 rows. I chose the TableLayout because
I have a tablelayout in Android like this: 1) Row == IMAGEVIEW | TEXTVIEW
I have a TableLayout and some unknown number of TableRows that are generated based

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.