vanesxl
@vanesxl

Как два ImageView прилепить к разным краям экрана?

Здравствуйте, у меня есть 2 ImageView как сделать так, чтобы они были прилеплены 1 к левому краю экрана, другой к правому? При этом они должны находится на одной прямой?
Вот код моей XML:
<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>

Заранее большое спасибо!
  • Вопрос задан
  • 369 просмотров
Пригласить эксперта
Ответы на вопрос 3
newross
@newross
Product owner
Изменить свойства RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

Затем убрать LinearLayout и добавить соответствующим ImageView
android:layout_alignParentLeft="true"
и
android:layout_alignParentRight="true"
Ответ написан
Комментировать
gadfi
@gadfi
https://gamega.org
если используете LinearLayout то укажите android:orientation="horizontal" и между ними можете поставить View как наполнитель, а вообще судя по названиям вам нужен toolbar там вам и кошерное лого, и нормальное меню иконки, тем более в него можно ставить что угодно
Ответ написан
Prognosticator
@Prognosticator
TODO: Здесь будут ворованные умные мысли, типа мои
<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>
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы