Round off corners of a Dialog type layout

5

I have a Activity that is a type Dialog when opened and I want to round the corners in Style

What I have is the following, however it does not work

<style name="formularios" parent="Base.Theme.AppCompat.Light.Dialog">
    <item name="android:background">@color/formulario</item>
    <item name="android:radius">@dimen/from</item>
</style>

And in dimension

dimen name="from">15dp</dimen>

My activity has the applied theme of forms that extends from Style . Any ideas to implement this through XML or code?

    
asked by Ashley G. 31.12.2016 в 17:56
source

1 answer

2

According to this answer from SO in English this can be achieved by creating an xml that contains a shape .

This xml should be located in the Drawable folder and will have the following content:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid
        android:color="@color/white"/>
    <corners
        android:radius="30dp" />
    <padding
        android:left="10dp"
        android:top="10dp"
        android:right="10dp"
        android:bottom="10dp" />
</shape>

This file should be used as background in the layout xml in the following way:

android:background="@drawable/dialog_bg"

And finally put the BackgroundDrawable of dialog transparent in the following way:

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

Documentation

answered by 03.01.2017 / 15:41
source