Reputation: 6522
I have a 9-patch image and what I want to do is to use it to "seperate" the adMob ad from the app. I want to draw a light blue line exactly where the ad is.
This is the 9-patch:
I added it to layout as ImageView and this is the XML code:
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/ab_transparent_example" />
And this is the result:
But what I want to get is the 9-patch to take the size of the screen, to make a full blue line from left to right of the screen. I've never worked with 9-patch before, what am I doing wrong?
Upvotes: 0
Views: 579
Reputation: 3706
First you need to know is that 9-patch is image as any other, regarding layout placing it. The difference is in way 9- patch image scale.
In this situation, try to set layout_width to "fill_parrent" or "match_ parent"
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/ab_transparent_example" />
Upvotes: 0
Reputation: 15766
The diagram below is a pretty good visual explanation of what a 9-patch is. As for your specific problem, you should set the 9-patch as the background to the image.
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:background="@drawable/ab_transparent_example" />
Upvotes: 1