Android layout with colorful embroidery

Asked

Viewed 2,514 times

0

Hello,

Someone knows how I make rounded and colored edges on an android screen(layout). I believe there should be some configurable item in XML but I don’t know which and I’m not sure if it is possible. The idea is that it looks like a frame, only with the rounded corners.

Thank you!

2 answers

1

You will have to create a drawable with rounded corners and set it as your background layout or in any view as desired.

Follow an example with green edges:

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>

0

Just create a Shape rectangular in the folder drawable and define as background of his view:

drawable/embroider_blue.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 define the background of an 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.