Reputation:
I have some trouble with Android, and I can't figure out why.
I have created a simple XML file for the layout of my activity, but everytime my text is cut on the right of the screen, and I don't know why.
This is the code :
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".MenuPrincipal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:text="@string/titre_intro"
android:textAlignment="viewStart"
android:textColor="@android:color/holo_blue_dark"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<ScrollView
android:layout_width="368dp"
android:layout_height="254dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:fillViewport="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ultricies leo nec tellus imperdiet, quis tempor magna auctor. Vivamus eu elementum odio, a ultrices magna. Sed hendrerit, tellus ac iaculis tempus, tellus erat tempus odio, eget lacinia dolor purus eu nisi. Vivamus nec felis non ante elementum lobortis. Sed congue a tellus in tristique. Vivamus ac sem at quam condimentum accumsan ac non justo. Morbi fringilla dignissim cursus. Vestibulum nunc lacus, tempor et eros sit amet, rutrum interdum magna. In turpis sapien, tempor hendrerit placerat at, tempus vel est. Fusce et sem tellus. Vivamus eu blandit enim. Pellentesque vel imperdiet quam, finibus iaculis lectus. Nullam fermentum dolor nec fermentum tempus. Quisque tristique felis ut mauris gravida, eget malesuada urna aliquam. "
android:textAlignment="center" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
If someone has an idea, I really can't find the solution.
Upvotes: 0
Views: 69
Reputation: 54204
The problem is in your ScrollView tag:
<ScrollView android:layout_width="368dp" android:layout_height="254dp" ...>
The fixed width means that if your phone is smaller than 368dp wide, your text will be cut off. You already have the right constraints in place, so simply change the width to be 0dp
instead of 368dp
, and it will make the ScrollView be as wide as the phone.
The fixed height is also suspicious, but the width is the only thing that's affecting your text being cut off.
Upvotes: 1