Android: Activity with rounded edges

3

I am trying to make my main activity, which handles fragments, have rounded edges, a clear example is this image

How could I do that? I was trying with this that I found on the same page LINK .

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <corners android:radius="15dp" />

    <solid android:color="#565656" />

    <stroke
        android:width="3dp"
        android:color="#ffffff" />

    <padding
        android:bottom="6dp"
        android:left="6dp"
        android:right="6dp"
        android:top="3dp" />

</shape>

But I can not do anything, it shows absolutely nothing ... I do not know if I'm doing something wrong, or something is missing, BUT, if I do not use it as a STYLE and if I use BACKGROUND if it shows me, with the difference that instead of having the corners in black (simulating that it is screen off) shows me in white ...

Any suggestions? Thanks!

    
asked by LcsGrz 16.08.2018 в 21:53
source

1 answer

3

To achieve what you want you need a layer-list as you need 2 shape , this file will be saved within the /drawable directory of your project , for example layout_background.xml :

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >

<item>
    <shape android:shape="rectangle" >
        <solid android:color="#000000" />
    </shape>
</item>
<item>
    <shape>
        <solid android:color="#AAFFAA"/>
        <corners android:radius="20dp"/>
        <padding android:left="0dp" android:top="0dp" android:right="0dp" android:bottom="0dp" />
    </shape>
</item>

</layer-list>

This layer-list contains 2 shapes one for the color background black and one that contains the color green and has rounded edges.

The layer-list you should call it from the layout file that loads your Activity (using the setContentView(archivo layout) method) and add it in this way, example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    ...
    ...
    ...
    android:background="@drawable/layout_background">

This way you will get the aactvity:

Also if you want you can hide the status bar

how to remove notification bar?

    
answered by 16.08.2018 / 22:41
source