Solution 1 :
Use android:maxLength="32"
Hope this helps.
Solution 2 :
If you want second text show only in first line you can do this
<TextView
android_id="@+id/textView_profile_name"
android_layout_width="0dp"
android_layout_height="wrap_content"
android_textColor="@color/dark_gray"
android_textSize="@dimen/textSize"
app_layout_constrainedWidth="true"
android_fontFamily="@font/helvetica_neue_light"
android_maxLines="1"
android_text="Hello"
app_layout_constraintStart_toEndOf="@id/img_profile"
app_layout_constraintEnd_toStartOf="@id/textView_profile_device_count"
app_layout_constraintTop_toTopOf="parent" />
<TextView
android_id="@+id/textView_profile_device_count"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginEnd="@dimen/dp30"
android_layout_marginStart="@dimen/dp_5"
android_singleLine="true"
app_layout_constrainedWidth="true"
app_layout_constraintEnd_toStartOf="@id/img_arrow"
android_textSize="@dimen/textSize"
app_layout_constraintTop_toTopOf="parent"
android_maxLines="1"
android_fontFamily="@font/helvetica_neue_light"
android_textColor="@color/dark_gray"
app_layout_constraintBottom_toBottomOf="@id/img_profile"
android_text="(3 Devices)" />
With this, you second text will always stay in first line. And first text length will set to 0dp it means that first text length will start from end of img_profile
to start of textView_profile_device_count
But it may still have some problem if text of first textview wider than width of textview, and it will not fully show.
PS. Sorry for my bad English.
Problem :
My question is both are two separate textviews “Hello” and “World” First textview has character limit of 32. How can I make it wrap content if text exceeds the limit and make “World” stay in first line?
Below is the image thats how its acting currently.
Below is the code which I tried to implement. I tried to write min_ems, max_ems and ems but its not looking good in tablet.
<ImageView
app_layout_constraintStart_toStartOf="parent"
android_id="@+id/img_profile"
android_layout_width="@dimen/image_width"
android_layout_height="@dimen/image_height"
android_src="@drawable/active_profile"
app_layout_constraintTop_toTopOf="parent"
app_layout_constraintRight_toLeftOf="@id/textView_profile_name"
tools_ignore="ContentDescription" />
<TextView
android_id="@+id/textView_profile_name"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_textColor="@color/dark_gray"
android_textSize="@dimen/textSize"
app_layout_constrainedWidth="true"
android_fontFamily="@font/helvetica_neue_light"
android_text="Hello"
app_layout_constraintLeft_toRightOf="@id/img_profile"
app_layout_constraintRight_toLeftOf="@id/textView_profile_device_count"
android_maxLines="2"
android_maxEms="12" **//this code can be a typo I added in stackoverflow**
android_minEms="2" **//this code can be a typo I added in stackoverflow**
app_layout_constraintTop_toTopOf="parent" />
<TextView
android_id="@+id/textView_profile_device_count"
android_layout_width="wrap_content"
android_layout_height="wrap_content"
android_layout_marginEnd="@dimen/dp30"
android_layout_marginStart="@dimen/dp_5"
android_singleLine="true"
app_layout_constrainedWidth="true"
app_layout_constraintStart_toEndOf="@id/textView_profile_name"
app_layout_constraintEnd_toStartOf="@id/img_arrow"
android_textSize="@dimen/textSize"
app_layout_constraintTop_toTopOf="parent"
android_maxLines="1"
android_fontFamily="@font/helvetica_neue_light"
android_textColor="@color/dark_gray"
app_layout_constraintBottom_toBottomOf="@id/img_profile"
android_text="(3 Devices)" />
<ImageView
tools_ignore="ContentDescription"
android_id="@+id/img_arrow"
android_layout_width="@dimen/dp20"
app_layout_constraintTop_toTopOf="parent"
app_layout_constraintLeft_toRightOf="@id/textView_profile_device_count"
app_layout_constraintVertical_weight="1"
android_layout_height="@dimen/dp20"
android_src="@drawable/ic_arrow_forward_black_24dp"
app_layout_constraintEnd_toEndOf="parent"
/>
Comments
Comment posted by stackoverflow.com/questions/4851659/…
Check this SO will help you :
Comment posted by Darpal
@Manjuboyz It kind of solved the issue, the only thing is if you write small text in first textview, then its leaving space between two textviews.
Comment posted by Darpal
yes I added that later, but my issue is
Comment posted by Darpal
its not working out. if you