Reputation: 167
Is it possible to assign the left border to an image in like my attached image in which it have left strip border?
We need to assign the image to border or we can do it with border image ? Can anyone please Help?
Thanks in advance.
Here is the sample image:
Result after apply the code:
Upvotes: 2
Views: 113
Reputation: 1924
try this, I have done it.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/tcit" />
<View
android:layout_width="5dp"
android:layout_height="match_parent"
android:background="#336699" />
</RelativeLayout>
In your layout file, if you need it in landscape, just do it the same orientation which you need, and I have attached a snapshot for this, kindly have a look to it.
Upvotes: 2
Reputation: 4213
You could always just set a background color (or even another image) to the ImageView and give it a left padding:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ff0000"
android:paddingLeft="20dp"
android:src="@drawable/image_res" />
Upvotes: 1
Reputation: 4570
You can easily achieve this by:
Method 1 - where you don't want to overlap that small part of the image:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<View
android:layout_width="8dp"
android:layout_height="match_parent"
android:background="#FF0000" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/my_image" />
</LinearLayout>
Method 2 - where you want to overlap the image with the border:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/my_image" />
<View
android:layout_width="8dp"
android:layout_height="match_parent"
android:background="#FF0000" />
</RelativeLayout>
Upvotes: 2
Reputation: 1064
You can easily achieve this by creating one layout over another, setting the colors required in your background layout and adding a left margin to the upper layout.
Upvotes: 1