Solution 1 :
You just need to add this line to the TextView android:layout_weight="1"
this is the final XML
<LinearLayout
android_layout_width="match_parent"
android_layout_height="wrap_content">
<TextView
android_id="@+id/profileNickname"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_weight="1"
android_gravity="center"
android_scrollHorizontally="false"
android_text="No Nickname yet fdg d trdt rdrt tdr td trd t"
android_textColor="#FFF"
android_textSize="24sp"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toEndOf="parent"
app_layout_constraintTop_toTopOf="parent" />
<ImageView
android_id="@+id/btnEditNickname"
android_layout_width="42dp"
android_layout_height="42dp"
android_layout_marginLeft="8dp"
android_layout_gravity="center"
android_padding="6dp"
android_scaleType="fitXY"
app_srcCompat="@android:drawable/ic_menu_edit" />
</LinearLayout>
Solution 2 :
Try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto"
android_layout_width="match_parent"
android_layout_height="match_parent"
android_gravity="center"
android_orientation="horizontal">
<LinearLayout
android_layout_width="0dp"
android_layout_height="wrap_content"
android_layout_weight="1">
<TextView
android_id="@+id/profileNickname"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_gravity="center"
android_scrollHorizontally="false"
android_text="No Nickname yet fdg d trdt rdrt tdr td trd t"
android_textColor="#FFFFFF"
android_textSize="24sp" />
</LinearLayout>
<LinearLayout
android_layout_width="wrap_content"
android_layout_height="wrap_content">
<ImageView
android_id="@+id/btnEditNickname"
android_layout_width="42dp"
android_layout_height="42dp"
android_layout_marginLeft="8dp"
android_padding="6dp"
android_scaleType="fitXY"
app_srcCompat="@android:drawable/ic_menu_edit" />
</LinearLayout>
</LinearLayout>
It’ll give you the following result:
And don’t forget to change the text color of the textView to that you want.
Problem :
This is the Layout:
<LinearLayout
android_layout_width="0dp"
android_layout_height="wrap_content"
android_gravity="center"
android_orientation="horizontal"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toStartOf="parent"
app_layout_constraintTop_toBottomOf="@id/profileUserImage">
<TextView
android_id="@+id/profileNickname"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_gravity="center"
android_scrollHorizontally="false"
android_text="No Nickname yet fdg d trdt rdrt tdr td trd t"
android_textColor="@color/colorText"
android_textSize="24sp"
app_layout_constraintBottom_toBottomOf="parent"
app_layout_constraintEnd_toEndOf="parent"
app_layout_constraintStart_toEndOf="parent"
app_layout_constraintTop_toTopOf="parent" />
<ImageView
android_id="@+id/btnEditNickname"
android_layout_width="42dp"
android_layout_height="42dp"
android_layout_marginLeft="8dp"
android_padding="6dp"
android_scaleType="fitXY"
app_srcCompat="@android:drawable/ic_menu_edit" />
</androidx.appcompat.widget.LinearLayoutCompat>
When profileNickname
is getting too long, it pushes out btnEditNickname
out of the LinearLayout and also overlays itself out of the Layout a bit before the text is getting wrapped. How can I get this annoying piece of c*** to wrap IN TIME, before ruining everything?? I’m getting sick of wasting hours of time for minor bs like that, I hate android!