Reputation: 1
I have a question. I've done in XML ImageView. Unfortunately, the "holds" on the left side of the screen on the phone. I wish this picture could shift to the right place. I would like to point to the X and Y position of the image shifted to the indicated place. How do I do this? Please explain in detail because I am a novice programmer of Java. Sorry for the mistakes. I'm not saying every day in the English language.
Upvotes: 0
Views: 1722
Reputation: 39604
I'd not recommend setting fixed positions for elements as it will make your life only harder for different screen sizes.
Use a RelativeLayout
. Here is an example of how your XML could look like.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_alignParentRight="true"/>
</RelativeLayout>
This way the ImageView
will always be bound to its parents right side. This is achieved by setting android:layout_alignParentRight="true"
on the ImageView
.
Hope it helps.
Upvotes: 1