Image displaying off the screen - Android studio
For some reason when I set the x coordinate to screen_width - image_width, the image is displayed off the screen. The same scenario occurs with the y coordinate. Here is my code.
public class MainActivity extends AppCompatActivity {
ImageView image;
float height;
float width;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
height = displayMetrics.heightPixels;
width = displayMetrics.widthPixels;
image.setImageResource(R.drawable.pigeon);
image.setX(width - image.getMeasuredWidth());
In this case the image, which is a pigeon, is not displayed on the screen. And I expect it to be displayed so that the right border of the pigeon touches the right border of the screen.
Edit: It's not that I just want to position the image and be done with it. I want to be able to move the image to precise coordinates while the app is running, such as when a mouse click occurs.
java android android-studio
|
show 4 more comments
For some reason when I set the x coordinate to screen_width - image_width, the image is displayed off the screen. The same scenario occurs with the y coordinate. Here is my code.
public class MainActivity extends AppCompatActivity {
ImageView image;
float height;
float width;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
height = displayMetrics.heightPixels;
width = displayMetrics.widthPixels;
image.setImageResource(R.drawable.pigeon);
image.setX(width - image.getMeasuredWidth());
In this case the image, which is a pigeon, is not displayed on the screen. And I expect it to be displayed so that the right border of the pigeon touches the right border of the screen.
Edit: It's not that I just want to position the image and be done with it. I want to be able to move the image to precise coordinates while the app is running, such as when a mouse click occurs.
java android android-studio
just wondering why dont you set the width and height of the image in the xml?match_parentdoes the job
– Mohammad Julfikar
Dec 28 '18 at 3:33
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
1
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22
|
show 4 more comments
For some reason when I set the x coordinate to screen_width - image_width, the image is displayed off the screen. The same scenario occurs with the y coordinate. Here is my code.
public class MainActivity extends AppCompatActivity {
ImageView image;
float height;
float width;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
height = displayMetrics.heightPixels;
width = displayMetrics.widthPixels;
image.setImageResource(R.drawable.pigeon);
image.setX(width - image.getMeasuredWidth());
In this case the image, which is a pigeon, is not displayed on the screen. And I expect it to be displayed so that the right border of the pigeon touches the right border of the screen.
Edit: It's not that I just want to position the image and be done with it. I want to be able to move the image to precise coordinates while the app is running, such as when a mouse click occurs.
java android android-studio
For some reason when I set the x coordinate to screen_width - image_width, the image is displayed off the screen. The same scenario occurs with the y coordinate. Here is my code.
public class MainActivity extends AppCompatActivity {
ImageView image;
float height;
float width;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
height = displayMetrics.heightPixels;
width = displayMetrics.widthPixels;
image.setImageResource(R.drawable.pigeon);
image.setX(width - image.getMeasuredWidth());
In this case the image, which is a pigeon, is not displayed on the screen. And I expect it to be displayed so that the right border of the pigeon touches the right border of the screen.
Edit: It's not that I just want to position the image and be done with it. I want to be able to move the image to precise coordinates while the app is running, such as when a mouse click occurs.
java android android-studio
java android android-studio
edited Dec 28 '18 at 7:19
asked Dec 27 '18 at 16:26
Jonathan
1477
1477
just wondering why dont you set the width and height of the image in the xml?match_parentdoes the job
– Mohammad Julfikar
Dec 28 '18 at 3:33
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
1
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22
|
show 4 more comments
just wondering why dont you set the width and height of the image in the xml?match_parentdoes the job
– Mohammad Julfikar
Dec 28 '18 at 3:33
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
1
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22
just wondering why dont you set the width and height of the image in the xml?
match_parent does the job– Mohammad Julfikar
Dec 28 '18 at 3:33
just wondering why dont you set the width and height of the image in the xml?
match_parent does the job– Mohammad Julfikar
Dec 28 '18 at 3:33
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
1
1
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22
|
show 4 more comments
1 Answer
1
active
oldest
votes
One way to align the image right is to use the XML layout. This is the easiest method.
Assuming you have an ImageView inside a RelativeLayout you can use the `layout_alignParentRight' attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
The layout_alignParentEnd attribute is an alternative for layout_alignParentRight for right to left language script. For a LinearLayout you can use layout_gravity attribute. Also, ensure that your ImageView is wrap_content and not match_parent in which case the image will expand to fill the entire ImageView.
If you want to do it programmatically, you can do it in the following manner:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.pigeon);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageView.setLayoutParams(params);
}
Here we are aligning the child view of RelativeLayout right by adding the align right rule and then setting that layout parameter for the Image View. This can also be done for LinearLayout using layout_gravity feature.
I have tested this code for a sample image. Hope this solves your problem.
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948018%2fimage-displaying-off-the-screen-android-studio%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
One way to align the image right is to use the XML layout. This is the easiest method.
Assuming you have an ImageView inside a RelativeLayout you can use the `layout_alignParentRight' attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
The layout_alignParentEnd attribute is an alternative for layout_alignParentRight for right to left language script. For a LinearLayout you can use layout_gravity attribute. Also, ensure that your ImageView is wrap_content and not match_parent in which case the image will expand to fill the entire ImageView.
If you want to do it programmatically, you can do it in the following manner:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.pigeon);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageView.setLayoutParams(params);
}
Here we are aligning the child view of RelativeLayout right by adding the align right rule and then setting that layout parameter for the Image View. This can also be done for LinearLayout using layout_gravity feature.
I have tested this code for a sample image. Hope this solves your problem.
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
add a comment |
One way to align the image right is to use the XML layout. This is the easiest method.
Assuming you have an ImageView inside a RelativeLayout you can use the `layout_alignParentRight' attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
The layout_alignParentEnd attribute is an alternative for layout_alignParentRight for right to left language script. For a LinearLayout you can use layout_gravity attribute. Also, ensure that your ImageView is wrap_content and not match_parent in which case the image will expand to fill the entire ImageView.
If you want to do it programmatically, you can do it in the following manner:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.pigeon);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageView.setLayoutParams(params);
}
Here we are aligning the child view of RelativeLayout right by adding the align right rule and then setting that layout parameter for the Image View. This can also be done for LinearLayout using layout_gravity feature.
I have tested this code for a sample image. Hope this solves your problem.
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
add a comment |
One way to align the image right is to use the XML layout. This is the easiest method.
Assuming you have an ImageView inside a RelativeLayout you can use the `layout_alignParentRight' attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
The layout_alignParentEnd attribute is an alternative for layout_alignParentRight for right to left language script. For a LinearLayout you can use layout_gravity attribute. Also, ensure that your ImageView is wrap_content and not match_parent in which case the image will expand to fill the entire ImageView.
If you want to do it programmatically, you can do it in the following manner:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.pigeon);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageView.setLayoutParams(params);
}
Here we are aligning the child view of RelativeLayout right by adding the align right rule and then setting that layout parameter for the Image View. This can also be done for LinearLayout using layout_gravity feature.
I have tested this code for a sample image. Hope this solves your problem.
One way to align the image right is to use the XML layout. This is the easiest method.
Assuming you have an ImageView inside a RelativeLayout you can use the `layout_alignParentRight' attribute as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/image_name"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
/>
</RelativeLayout>
The layout_alignParentEnd attribute is an alternative for layout_alignParentRight for right to left language script. For a LinearLayout you can use layout_gravity attribute. Also, ensure that your ImageView is wrap_content and not match_parent in which case the image will expand to fill the entire ImageView.
If you want to do it programmatically, you can do it in the following manner:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageView);
imageView.setImageResource(R.drawable.pigeon);
RelativeLayout.LayoutParams params = new
RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
imageView.setLayoutParams(params);
}
Here we are aligning the child view of RelativeLayout right by adding the align right rule and then setting that layout parameter for the Image View. This can also be done for LinearLayout using layout_gravity feature.
I have tested this code for a sample image. Hope this solves your problem.
answered Dec 28 '18 at 6:25
Neelabh
13
13
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
add a comment |
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
Its not that I just want to initialize the location of the image though. I want to be able to position it dynamically (to precise coordinates) such as on a mouse click. For example, maybe I want the image to move to position (374, 116) after a mouse click.
– Jonathan
Dec 28 '18 at 7:13
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
You can set params.leftMargin and params.topMargin with the precise coordinates. In your example. params.leftMargin = 374, and params.topMargin = 116. And then set the imageView.setLayoutParams(params). This should do the trick.
– Neelabh
Dec 28 '18 at 10:01
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
Thanks, I will try that
– Jonathan
Dec 28 '18 at 16:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53948018%2fimage-displaying-off-the-screen-android-studio%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
just wondering why dont you set the width and height of the image in the xml?
match_parentdoes the job– Mohammad Julfikar
Dec 28 '18 at 3:33
I did. I'm only trying to set the position of the image here. The width and height are already set.
– Jonathan
Dec 28 '18 at 4:06
Are you trying to set the position to (0,0)
– Mohammad Julfikar
Dec 28 '18 at 4:12
No, I want to set the position such that the right border of my image, touches the right border of the phone screen.
– Jonathan
Dec 28 '18 at 4:19
1
Then it's totally different story. you can refer to this answer: stackoverflow.com/a/9398861/7081771
– Mohammad Julfikar
Dec 28 '18 at 7:22