Android rounding error

I'm trying to create an incomplete Activity screen with transparency around it and use this XML layout:

<?xml version="1.0" encoding="utf-8"?> <merge xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/containerPageContainer"> <FrameLayout android:id="@+id/informationContainer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" > <LinearLayout android:id="@+id/myContainer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:background="@drawable/rounder_corners" android:orientation="vertical" android:padding="10dp" > </LinearLayout> </FrameLayout> </merge> 

And for rounded corners:

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFFFF" /> <corners android:radius="10dp" /> </shape> 

But we got this result with defects in the corners, lower and upper sides:

enter image description here

Help me fix it.

+4
source share
2 answers

I found a solution:

1) Create an XML theme in res/values/ :

 <?xml version="1.0" encoding="utf-8"?> <resources xmlns:android="http://schemas.android.com/apk/res/android"> <style name="Theme.Transparent" parent="android:Theme"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">true</item> <item name="android:backgroundDimEnabled">false</item> </style> </resources> 

2) Style of rounded corners drawable/rounded_corners.xml :

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" android:padding="10dp"> <solid android:color="#FFFFFFFF" /> <corners android:radius="10dp" /> </shape> 

3) XML action:

 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/qrCodeContainer" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="center_horizontal" android:background="@drawable/rounder_corners" android:orientation="vertical" android:padding="15dp" android:layout_margin="6dp" > </RelativeLayout> </RelativeLayout> 

4) Describe Activity in the manifest of the XML project:

 <activity android:name=".view.ViewCodeActivity" android:label="@string/app_name" android:theme="@style/Theme.Transparent"> </activity> 
+5
source

Covering an AlertDialog thematic presentation with a form is not a good idea, as you can see.
There you have a tutorial:
http://darshangr.wordpress.com/2011/06/23/creating-a-transparent-view-in-android-login-screen-example/

Naturally, you will need to change it. Instead of a white backgroud, set a shape with rounded corners.

+1
source

Source: https://habr.com/ru/post/1436852/


All Articles