xml - Curved edges on Activity android -


i trying create pop-up window curved edges. saw there existing question similar year ago many answers tried out , none of solve problem @ hand. ultimately, creating activity have curved edges itself, however, there white background has corners beneath effect not work. additionally, trying display on other activity using intents creates whole new screen , blacks out space not taken activity. appreciate help, thank you.this activity looks right now

xml format:

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

java code initializing window:

confirmlayout = (relativelayout) findviewbyid(r.id.confirm_window);     getwindow().setlayout(width,height);     confirmlayout.setgravity(relativelayout.center_vertical);     confirmlayout.setbackgroundresource(r.drawable.justcurves); 

xml window itself:

<?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="match_parent" android:layout_height="match_parent" android:id="@+id/confirm_window" tools:context="com.exampleryancocuzzo.ryan.markettycoon.confirmwindow" android:background="@color/greenyellow" >  <textview     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:text="press confirm proceed"     android:textsize="25sp"     android:gravity="center"     android:textstyle="bold"     android:layout_centervertical="true"     />  <button     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="confirm"     android:padding="10dp"     android:layout_alignparentbottom="true"     android:layout_margin="5dp"     android:textcolor="@color/white"     android:background="@color/black"     android:onclick="confirmed"     /> <button     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="cancel"     android:padding="10dp"     android:layout_alignparentbottom="true"     android:layout_alignparentright="true"     android:layout_margin="5dp"     android:textcolor="@color/white"     android:background="@color/darkgray"     android:onclick="cancelled"     />  </relativelayout> 

for make activity curved edges, can define own theme in styles.xml..!

please check below example idea it,

rounded_drawable.xml

<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" /> 

next make own theme extends parent theme.dialog in styles.xml:

<style name="themewithcorners" parent="android:theme.dialog">     <item name="android:windowbackground">@drawable/another_test_drawable</item> </style> 

and in manifest, add theme in activity tag,

<activity     android:name=".activityname"     android:label="@string/app_name"     android:theme="@style/themewithcorners" > 

thats all! more info styles, can refer the below url: http://developer.android.com/guide/topics/ui/themes.html


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -