Winny
Winny

Reputation: 131

Android table layout: border?

I am trying to have a border around a layout but can’t seem to make it work . Here’s what I have, and I’m trying to get something like the border shown on this.

enter image description here

enter image description here

My XML is this:

<TableLayout
    android:layout_width="110dp"
    android:layout_height="75dp"
    android:layout_marginStart="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginBottom="220dp"
    app:layout_constraintBottom_toBottomOf="parent"
    android:background="#B79494"
    app:layout_constraintStart_toStartOf="parent">

    <TableRow
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:baselineAligned="false">
        android:color="@color/colorPrimaryDark"
        android:width="4dp"
        android:background="#C5BBBB"

       <TextView
            android:id="@+id/homeTest1"
            android:layout_width="47dp"
            android:layout_height="54dp"
            android:gravity="center"
            android:padding="0.25dip"
            android:text="Space Line" />

          <TextView
             android:id="@+id/SowTest1"
             android:layout_width="25dp"
             android:layout_height="30dp"
             android:gravity="center"
             android:padding="0.25dip"
             android:text="A test"
             android:textSize="12sp">
         </TextView>

        </TableRow>

 </TableLayout>

Amy help please? Cheers

Upvotes: 0

Views: 52

Answers (1)

Prajwal Waingankar
Prajwal Waingankar

Reputation: 2718

Simply do this:

  1. Place your TableLayout inside of a Relative Layout for better results i.e. Relative Layout is the parent of TableLayout.
  2. Then add the background color as Black to your Relative Layout.
  3. Add an equal margin of 10dp or so as per your req. To your TableLayout.

Upvotes: 1

Related Questions