У меня есть изображениеView в центре моей Relative Layout, и я хочу центрировать два TextViews под ImageView. Но это не работает.Как можно центрировать два текстовых изображения в RelativeLayout
Вот скриншот:
Я хочу центрирования "Текст 1" и "Текст 2" под изображением.
Вот код XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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"
tools:context="com.example.googlemap.TestActivity"
android:background="@color/white">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Title"/>
<ImageView
android:id="@+id/imageView1"
android:layout_width="200dp"
android:layout_height="150dp"
android:layout_below="@id/titleTextView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_margin="15dp"
android:contentDescription="Desc"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imageView1"
android:textSize="25sp"
android:text="Text 1" />
<TextView
android:id="@+id/numOfPlayersTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/imageView1"
android:layout_toEndOf="@id/textView2"
android:text="Text 2"
android:textSize="25sp"
android:layout_marginStart="20dp" />
</RelativeLayout>
</ScrollView>
добавить * андроида: SRC = "@ Drawable/ic_launcher" * (нет изображения ЦСИ в моем коде). Я обновлю его – Rami
oh ok. Благодаря!! – BreakThePause
вопрос: Если я хочу добавить несколько текстовых элементов под «Text1» и «Text2», следует ли добавлять линейные макеты внутри созданного вами линейного макета? – BreakThePause