Effect: text on the left, icon on the right
When text is short, an icon relies only on text
When the text is long, the text wraps and the icon is on the right
<TextView
android:id="@+id/chargingTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="10dp"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintEnd_toStartOf="@+id/chargingPrepareIcon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolbar_layout"
/>
<ImageView
android:id="@+id/chargingPrepareIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/base_icon_warning"
android:layout_marginStart="8dp"
android:layout_marginEnd="24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/chargingTitle"
app:layout_constraintTop_toTopOf="@+id/chargingTitle"
app:layout_constraintBottom_toBottomOf="@+id/chargingTitle"
/>
If the text is too long in the ConstraintLayout, the TextView will exceed the constraint.
Read More:
- [Android] ImageView setting background image error: error inflating class ImageView
- java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
- Error inflating class TextView [How to Solve]
- How to empty a whole line in latex (simple and effective)
- How to terminate the current program under linux command line?
- How to Fix Parser rerror: error tokenizing data. C error: expected 2 fields in line 53, saw 3
- Java 8 Stream – Read a file line by line
- How does a Mac terminal exit the python command line
- Three ways of single line and multi line comment in Python
- Let’s get started with latex 05, line feed, paragraph feed, page feed, first line indent, etc
- The language of C__ FILE__ 、__ LINE__ And line
- Command line is too long. Shorten command line for QuestionnaireApplication or also for Spring Boot
- Error running ‘application’: command line is too long. Short command line for application
- Solution to the problem that SQL database query result field contains new line character, which leads to copy to excel dislocation
- Several ways for Ubuntu to open command line terminal window
- LaTeX Error: There’s no line here to end
- Use subprocess to execute the command line, and the pipeline is blocked
- Three solutions to command line flashback in VS
- [TS] solutions to line 0: parsing error: cannot read property ‘map’ of undefined