Я работаю над Android-приложением, где я хочу выровнять 2 линейных макета в строке с представлением изображения между этими двумя макетами. Я не могу использовать редактор макетов студии Android для достижения этой цели.Выравнивание 2 линейных макета и просмотр изображений внутри Относительная компоновка
Код для макета:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/nav_header_container"
android:layout_width="match_parent"
android:layout_height="160dp"
android:background="@color/colorPrimary">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:orientation="vertical"
android:layout_marginEnd="17dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true">
<TextView
android:text="DEFG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView8"
android:layout_gravity="center"
/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView16"
tools:text="1250"
android:textSize="30sp"
android:textColorLink="?attr/colorBackgroundFloating" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/rounded_corner"
android:layout_marginEnd="30dp"
android:layout_toStartOf="@+id/profile_image">
<TextView
android:text="ABCD"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView3"
android:layout_gravity="center"
/>
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView13"
tools:text="1250"
android:textSize="30sp"
android:textColorLink="?attr/colorBackgroundFloating" />
</LinearLayout>
<ImageView
android:id="@+id/profile_image"
android:layout_width="60dp"
android:src="@drawable/face"
android:layout_height="60dp"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/drawerList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>
</LinearLayout>
Выходной ток:
Ожидаемый результат:
2 линейных макетов в ряд с точки зрения изображения на центр относительной компоновки (с G Reen фон)
Я делаю что-то неправильно с расположением макета? Как реализовать такой сценарий?
Кажется, вы новичок в андроиде развития, жаль, что я не буду отправлять ответ! Я хочу, чтобы вы играли с макетом и кодом xml, это поможет вам научиться этому отлично! –
Вы должны использовать вес в линейном макете –
@PareshMayani sir, Какой комментарий: p –