Answer the question
In order to leave comments, you need to log in
How to set the exact position of an ImageView?
For example, I have a ready-made background and I need to make sure that the ImageView that I place on this background occupies a certain location at all resolutions. I tried to set the location based on the location as a percentage of the edges of the screen, but still there is a shift at different resolutions, which drastically spoils everything.
How can you create such a thing so that everything is in its place on any device?
Answer the question
In order to leave comments, you need to log in
android:layout_marginTop="10dp"
android:layout_gravity="center_horizontal"
<?xml version="1.0" encoding="utf-8"?>
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="@drawable/hangar"
tools:context="samsung.ru.spacex.Hangar">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_widthPercent="12%"
app:layout_heightPercent="70%"
app:layout_marginLeftPercent="8%"
app:layout_marginBottomPercent="6%"
android:background="@drawable/rocket_1"
android:id="@+id/imageButton5"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question