Hayya ANAM
Hayya ANAM

Reputation: 575

how to curve layout corner?

this is my nested layout how do i change its corner to curve?? image url 1 is a sample i want to do curve like that which implement inblack berry image url 2 is my android code how do i curve layout like that?? url1 is https://i.sstatic.net/KJfnP.jpg url 2 is https://i.sstatic.net/FrAFf.jpg

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="500dp"

    android:background="#D3D3D3"
    android:orientation="vertical"
    android:paddingLeft="3dip"
    android:paddingRight="3dip"
    >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="120dp"

        android:background="#333333"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/btnMiniStatement"
            style="@style/HomeButton"
            android:layout_width="wrap_content"
            android:drawableTop="@drawable/home_button1"
            android:onClick="onClickFeature"
            android:text="MINI STATEMENT" />

        <Button
            android:id="@+id/btnBalanceInquiry"
            style="@style/HomeButton"
            android:layout_width="wrap_content"
            android:drawableTop="@drawable/home_button2"
            android:onClick="onClickFeature"
            android:text="Balance Inquiry" />

        <Button
            android:id="@+id/btnUtilityBalanceInquiry"
            style="@style/HomeButton"
            android:layout_width="wrap_content"
            android:drawableTop="@drawable/home_button3"
            android:onClick="onClickFeature"
            android:text="Utility Balance Inquiry" />
    </LinearLayout>

Upvotes: 2

Views: 3561

Answers (1)

Adam Monos
Adam Monos

Reputation: 4307

In res/drawable create a new file (curved_bg.xml for example). In that file put:

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

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

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

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

</shape>

In your layout file set this as the background on your inner LinearLayout

android:background="@drawable/curved_bg"

Upvotes: 7

Related Questions