Android layout with colorful embroidery

0

Hello,

Does anyone know how to make rounded and colored borders on an android screen (layout). I believe there should be some configurable item in XML but I do not know which one and I'm not sure if it's possible. The idea is that it stays like a frame, but with rounded corners.

Thank you!

    
asked by anonymous 17.05.2016 / 03:50

2 answers

1

You will have to create a drawable with rounded corners and set it as your layout background or any view / p>

Here is an example with green borders:

drawable / rounded.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <stroke android:width="1dip" android:color="#79FF4D" />
    <corners android:radius="5dp" />
</shape>

layout / activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded"
    android:layout_gravity="center">

</RelativeLayout>
    
19.05.2016 / 20:10
0

Simply create a Shape in rectangle format in the drawable folder and set it to background of your view :

drawable / border_azul.xml

<shape
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="rectangle" >

   // A cor do background
   <solid android:color="#FF0099FF" />

   // Borda (tamanho e cor)
   <stroke android:width="1dip" android:color="#d4d4d4" />

   // Arredondamento das bordas
   <corners
       android:bottomRightRadius="5dp"
       android:bottomLeftRadius="5dp"
       android:topLeftRadius="5dp"
       android:topRightRadius="5dp"/>

</shape>

And set the background of some element like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/borda_azul">

      ...Seus componentes (Botões, etc)

</LinearLayout>
    
19.05.2016 / 20:33