Ferdau
Ferdau

Reputation: 1558

BackgroundImage repeat + rounded corners

So I should display a schedule, where every item has a background image with rounded corners...

I can't find out how to give my view (currently a TextView but I could change that) a background (which is a pattern that has to be repeated) and give it rounded corners...

All I can find is how to give rounded corners with a solid background color...

Could anyone help out?

EDIT: backgroundimage looks like this http://www.photoshop-pack.com/tutorials/images/1145.gif


A background image with rounded corners: not all items on the schedule have the same length

Left corners + main bg + Right corners: bg should repeat so the right corners wouldnt lineup with the center bg

Upvotes: 0

Views: 1992

Answers (3)

Aditya
Aditya

Reputation: 389

let me post my code here I have back_repeat.xml in drawable folder

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/repeat" 
android:tileMode="repeat" />

and repeat.gif in drawable folder which is backgroundimage from u r link.

also list_bkg_rounded.xml in drawable folder which is rounded border

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> 
     <stroke android:width="1dp" android:color="#fc9700"/>
     <corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" 
     android:topLeftRadius="10dp" android:topRightRadius="10dp"/> 
     <solid android:color="#fc9700"/>
 </shape>

and my main.xml is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    >
<LinearLayout 
     android:padding="4dip"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/list_bkg_rounded"
    android:gravity="center_horizontal"
    >
<TextView  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="hello all how are you ? "
    android:background="@drawable/back_repeat"
    />
</LinearLayout>  
</LinearLayout>

Upvotes: 1

Aditya
Aditya

Reputation: 389

Some thing similar to

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center_horizontal"
    >
<LinearLayout 
     android:padding="4dip"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/list_bkg_rounded"
    android:gravity="center_horizontal"
    >
<TextView  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="hello all how are you ? "
    android:background="@drawable/back_repeat"
    />
</LinearLayout>  
</LinearLayout>

I got something like this rounded pattern

Upvotes: 3

Aditya
Aditya

Reputation: 389

A background image with rounded corners: not all items on the schedule have the same length

Left corners + main bg + Right corners: bg should repeat so the right corners wouldnt lineup with the center bg

can u post layout image ?

Upvotes: 0

Related Questions