How can I make a table with a round border, similar to the photo below, in Android?
This example demonstrates how create a table with borders in Android . Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
Here's What To Do:Create a rounded shape drawable and set it as your view's background: android:background="@drawable/round_outline" Clip to outline in code: setClipToOutline(true)
I think Androidbase linked to the wrong question... he asked a similar question recently, and here's the answer I gave him:
You can put a coloured background with rounded corners into a table by using a Shape background. Create such a shape in an XML file, put in your drawables folder.
<?xml version="1.0" encoding="UTF-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#99FFFFFF"/> <corners android:radius="30px"/> <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" /> </shape>
For example the above creates a semi-transparent white background with 30px rounded corners. You set this to the table by using
android:background="@drawable/my_shape_file"
in the XML file where you defined your table layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With