Я знаю, что это звучит легко. Мне нужно поставить текст в центре, но когда текст слишком длинный, он должен идти ниже, но все равно выровняю в центре моего XML.
Вот мой код:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/showdescriptioncontenttitle"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_centerHorizontal="true"
>
<TextView
android:id="@+id/showdescriptiontitle"
android:text="Title"
android:textSize="35dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
Я поставил Paddingtop и снизу, потому что мне нужно некоторое пространство. PS: мой код больше; Это в релабривее.
android:layout_gravity="center"
или
android:gravity="center"
обе работы для меня.