In iOS, it is a line display of Android TextView, which is equivalent to UILabel. I was surprised today so I will share it. The premise is that after getting the character string to be displayed in Text by API communication, let UIKit setText and make it Label or TextView. It is a situation to display characters. If it's a fixed string, it can't be a story of such control!
By default, UILabel has two or more lines, but if the height of UILabel is a size that can display only one line, "1 line" is displayed as a character string, and the character breaks are abbreviated as "xxxx ...".
By default, if the number of characters is 2 or more lines, the TextView will be displayed. What was displayed as a character string was "1 line", and the part where the character was cut off was displayed as "xxxx".
So the dictator asked me to match the iOS specifications. It was the agenda this time to display "..." in the program.
label_text.xml
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@drawable/RED" />
Set ʻandroid: singleLineto
true and By setting ʻeandroid: ellipsize
to ʻend`, "xxxx ..." could be realized.
The ellipsize options are controlled as shown in the table below.
Value | TextView default value | motion |
---|---|---|
none | ○ | do nothing |
start | ...xxxx | |
middle | xxx...xxx | |
end | xxxxxx... |
At the development site of smartphone apps, most of the specifications are for iOS or Android, so You can realize a smart implementation by knowing in advance how the behavior changes between both OSs.
With that in mind, I'm currently studying Android SDK and UI.
Well, but I want to touch Kotlin soon.
Recommended Posts