Android table with round border

妖精的绣舞 提交于 2019-12-03 01:43:33

问题


How can I make a table with a round border, similar to the photo below, in Android?


回答1:


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.




回答2:


I prefer to use a masking technique - overlay a mask image (any iOS-style background, with a transparent cutout in it) over a standard layout.

This way, the background of my layout is not linked directly to a bitmap, I can change it very easily.

I have an answer explaining that here: Android XML rounded clipped corners




回答3:


I had a similar task recently so I decided to write a library for this purpose. Feel free to use it for your needs... https://github.com/vladexologija/GroupedTextView



来源:https://stackoverflow.com/questions/2387033/android-table-with-round-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!