Reputation: 3572
Here's a picture to help me explain my problem:
The black box is the whole screen. The red box is the TextView
. The green is the text. When I run my code, it looks like the left screen, but I want to it look as it does on the right. (start from left)
Here is the TextView
code:
<TextView
android:id="@+id/info_ruta"
android:layout_width="256dp"
android:layout_height="80dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/info_sumary"
android:textColor="#FFF"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/day_seven_id" />
When trying to add android:gravity="left"
or ="start"
it does not help with my problem. What am I missing here?
Upvotes: 1
Views: 249
Reputation: 2244
Use android:layout_width="match_parent"
and android:gravity="left"
on attributes of XML.
The match_parent
is fundamental for this.
Upvotes: 2
Reputation: 37404
use android:layout_width="match_parent"
instead of fixed width android:layout_height="80dp"
so it would be
<TextView
android:id="@+id/info_ruta"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="@string/info_sumary"
android:textColor="#FFF"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/day_seven_id" />
match_parent
with android:width
mean cover the complete width which is occupied by the parent container.
Upvotes: 2