André
André

Reputation: 25

TextView alignment in a Fragment

In my cardFragment, inside my Main Activity, I have these type of cards that show some country examples and their respective name. As you can see, the TextView with their name changes place according to the country name's lenght. What can I do to make the TextView locked to a left and Bottom position? Click here to see the image, please!

enter image description here

This is my XML:

<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">


<ImageView
    android:id="@+id/imgFotoPais"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

<TextView
    android:id="@+id/txtPaisNome"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="false"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="8dp"
    android:layout_marginEnd="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:text="TextView"
    android:textColor="@color/colorWhite"
    android:textSize="24sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.353"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="@+id/imgFotoPais"
    app:layout_constraintVertical_bias="0.9" />

</android.support.constraint.ConstraintLayout>

Upvotes: 1

Views: 874

Answers (1)

Mr. Roshan
Mr. Roshan

Reputation: 1805

Try this:-Put the following attribute in your TextView.

android:gravity:- for setting the gravity of the contents of the View.

android:layout_gravity:- for setting the gravity of the View or Layout relative to its parent Layout.

Upvotes: 1

Related Questions