I've seen this subject about puting a border around an android textview, and I used it. But now, I would like to put a border around widgets which are situated into a relative layout. How can I do it?

解决方案in your res/drawable folder, create a new file background_border.xml

In this file, you will define the background for widget like this:

android:shape="rectangle" >

android:color="@color/color_stroke"/>

android:topLeftRadius="5dp"

android:bottomRightRadius="5dp"

android:topRightRadius="0dp" />

android:endColor="@android:color/transparent"

android:angle="90"/>

set the background of your widget to the drawable configuration you've just created

eg. if you want to put your border on a relativelayout:

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="@drawable/background_border"

android:padding="15dp">

...

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐