Issue
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".MainActivity">
<TextView
android:id="@+id/pleaseChooseText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:textAlignment="center"
android:text="Please Choose your Mood"
android:textColor="@color/black"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
I want to make this text fill up screen width but not the screen height, would this work here or programatically, how do I do that?
Solution
You said you want the text to fill the screen width but not the height. The code below has set 'android:layout_height' to '0dp' which means the height will be as high as the constraints on the textview. And with the 'android:layout_width' set to match parent, it will be as wide as the parent. This means, as the text increases, it will fill the height until it reaches the constraints limits and then you won't see the rest of the text. If you want to see all your text, set the height to wrap_content like this 'android:layout_height="wrap_content"'. If you want to have a fixed height, then set the fixed pixels like 'android:layout_height="75dp"'.
Whatever you looking for is in the boundaries of what I have explained. If it helps you, an upvote would be appreciated.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".Activities.MainActivity">
<TextView
android:id="@+id/pleaseChooseText"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:gravity="center"
android:textAlignment="center"
android:text="Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. Please Choose your Mood. "
android:textColor="@color/black"
android:textStyle="bold"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Answered By - Dankyi Anno Kwaku