morg
morg

Reputation: 1191

Android/Eclipse : Image matching the screen's borders

I'm struggling to make an image match the borders of the screen. It's a 9 patch image. I've already asked the question (Android: Handling images size for multiple screens) but the answers I had are not satsfying at all so I'll try asking a more general question

If I want to set different layouts according to my screen width, I create a folder for large xlarge small and normal. But how could I preview the layout in the right screen? Eclips preview are several but as it said

xlarge screens are at least 960dp x 720dp
large screens are at least 640dp x 480dp
normal screens are at least 470dp x 320dp
small screens are at least 426dp x 320dp

I don't have the same results for 2 "normal screens" 480*854 or 480*800 so how could I proceed? I just want an image to match the layout's border I don't think it's that complicated, is it?

Upvotes: 0

Views: 275

Answers (1)

Jan
Jan

Reputation: 859

In your XML file try

<RelativeLayout 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/border_layout"
android:background="@drawable/border"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
    android:src="@drawable/icon1_1" />

</RelativeLayout>

These two parameters will help you align the layout .

       android:layout_alignParentLeft="true"
       android:layout_alignParentRight="true"

If your border is not the parent layout then replace above attributes with these .

         android:layout_alignLeft="@id/border"
         android:layout_alignRight="@id/border"

Upvotes: 1

Related Questions