Answer the question
In order to leave comments, you need to log in
How to stick two ImageViews to different screen edges?
Hello, I have 2 ImageViews, how can I make them stick 1 to the left edge of the screen, the other to the right? Do they have to be on the same line?
Here is my XML code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content"
android:layout_height="match_parent" android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/ActionBarCompat"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:baselineAligned="false">
<ImageView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/logo"
android:layout_marginLeft="10dp"
android:contentDescription="@string/logo"
android:layout_gravity="center_vertical" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView2"
android:src="@drawable/phone"
android:layout_gravity="center_vertical" />
</LinearLayout>
</RelativeLayout>
Answer the question
In order to leave comments, you need to log in
Change RelativeLayout Properties
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
if you use LinearLayout, then specify android:orientation="horizontal" and between them you can put View as a filler, but in general, judging by the names, you need a toolbar where you have both a kosher logo and a normal icon menu, especially since you can put anything in it
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context=".MainActivity">
<ImageView
android:id="@+id/imageView"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:contentDescription="@string/logo"
android:src="@drawable/logo"
android:layout_alignParentLeft="true" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/phone"
android:layout_alignParentRight="true"/>
</RelativeLayout>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question