1

I was Designing one activity with top Rounded Corners For Both left and Right with transparent

I was trying To Design something Like this enter image description here

i created a rounded_drawable.xml file and i implement that xml in my newlist.xml with android:background = "@drawable/rounded_drawable"

still my activity was not transparent and also it doesnot comes with rounded layout

here is what i designed

enter image description here

here is My Code :

rounded_drawable.xml

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


    <solid android:color="@color/transparent"

        />

    <corners android:topRightRadius="10dp"
        android:topLeftRadius="10dp"/>
</shape>

newlist.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background = "@drawable/rounded_drawable" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/l1"
        android:orientation="horizontal"

        >
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/close"
            android:src="@drawable/ic_close"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="100dp"
            android:layout_marginStart="100dp"
            android:layout_marginRight="15dp"
            android:layout_marginEnd="15dp"
            />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="60dp"
            android:fontFamily="@string/sans_serif_thin"
            android:text="@string/new_list"
            android:textStyle="bold"
            android:textSize="20dp"
            />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_check_circle"
            android:layout_marginTop="50dp"
            android:id="@+id/done"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"

            />

    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/l2"
        android:orientation="horizontal"
        android:layout_below="@+id/l1"
        android:layout_marginTop="20dp"

        >
        <ImageView
            android:layout_width="150dp"
            android:layout_height="150dp"
            android:id="@+id/img"
            android:src="@drawable/ic_image"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"
            />
        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/listname"
            android:hint="@string/enter_the_list_name"
            android:layout_marginEnd="50dp"
            android:layout_marginRight="50dp"
            android:layout_marginTop="60dp"
            android:layout_marginLeft="15dp"
            android:layout_marginStart="15dp"
            />

    </LinearLayout>
Karthickyuvan
  • 428
  • 2
  • 16
  • 2
    If the new transparent activity doesn't cover the whole screen, then why don't you use a DialogActivity or a Fragment? As I see from the above screenshot, activity behind can still be seen above the new one which means the transparent activity is about 80% of the screen? Am I right? which means you can use a Fragment instead. – Lalit Fauzdar Aug 09 '20 at 08:26
  • 1
    bcoz bro this Activity contains Images Below from there user can select one image and that was added in the image view near the EDIT TEXT – Karthickyuvan Aug 09 '20 at 08:55
  • 1
    Check [this - Rounded Corners DialogFragment](https://stackoverflow.com/a/44912145/8244632) out or [this](https://stackoverflow.com/a/46552297/8244632). – Lalit Fauzdar Aug 09 '20 at 09:02
  • 1
    Full tutorial Article - [How to make custom dialog with rounded corners in android](https://www.tutorialspoint.com/how-to-make-custom-dialog-with-rounded-corners-in-android). – Lalit Fauzdar Aug 09 '20 at 09:03

1 Answers1

2

create a new .xml file in drawable and paste this Code

<item>
    <shape android:shape="rectangle">

    </shape>
</item>
<item
    android:top="100dp"
    android:bottom="0dp"
    android:left="-70dp"
    android:right="-70dp">

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:innerRadius="50dp"
        android:shape="rectangle"
        android:useLevel="true">

        <solid android:color="@color/colorPrimary"/>
        <corners

            android:bottomLeftRadius="0dp"
            android:topLeftRadius="250dp"
            android:topRightRadius="250dp"/>

    </shape>
</item>

Also Add android:background = "@drawable/yourxmlfilename"

Karthick
  • 584
  • 4
  • 25