Ham*_*boh 188 android textview android-layout
我在EditText
我的布局中添加了一个,并添加了一个提示,并使其水平居中.
运行应用程序时,提示是不可见的.我发现我应该做ellipsize
的TextView
是start
:
<EditText
android:id="@+id/number1EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="start"
android:ems="10"
android:gravity="center_horizontal"
android:hint="@string/hint1" />
Run Code Online (Sandbox Code Playgroud)
在Android文档中,我读到:
如果设置,则导致比视图宽的单词被
椭圆化而不是在中间断开.
问题是ellipsize
在字典中找不到.任何人都可以向我解释一下我们可以通过ellipsize
属性获得哪些好处?和之间有什么区别start
,end
,middle
?
Zep*_*hyr 57
根据我的经验,省略号仅在设置了以下两个属性时才有效.
android:ellipsize="end"
android:singleLine="true"
Run Code Online (Sandbox Code Playgroud)
对于textview的宽度,wrap_content或match_parent都应该是好的.
Int*_*iya 17
How to Add an ellipsis in a TextView
android:ellipsize在API级别1中添加.省略号是连续三个句点.(...)
在你的Xml中
<TextView
....
android:text="Hi I am Amiyo,you can see how to ellipse works."
android:ellipsize = "end"
/>
Run Code Online (Sandbox Code Playgroud)
此时,省略号将不会显示,因为TextView设置为在输入新文本时默认自动展开.您需要以某种方式限制TextView.这样做,您可以使用添加到您TextView a scrollHorizontally, minLines, or maxLines
的省略号显示.
制作椭圆:
at the end: this is how it would...
use: android:ellipsize = "end"
Run Code Online (Sandbox Code Playgroud)
和
in the middle: this is ...how it would
use: android:ellipsize = "middle"
Run Code Online (Sandbox Code Playgroud)
和
at the start: ...this is how it would
use: android:ellipsize = "start"
Run Code Online (Sandbox Code Playgroud)
和
to have no ellipse
use: android:ellipsize = "none"
Run Code Online (Sandbox Code Playgroud)
请注意:
Do not use android:singeLine = "true", it is deprecated.
android:maxLines = "1" will not display the three dots (...)
android:lines = "1" will not display the three dots (...)
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请访问此处
http://developer.android.com/reference/android/widget/TextView.html#attr_android%3aellipsize
文本:
This is my first android application and
I am trying to make a funny game,
It seems android is really very easy to play.
Run Code Online (Sandbox Code Playgroud)
假设上面是你的文本,如果你使用ellipsize
的start
属性,它会像这样看到
This is my first android application and
...t seems android is really very easy to play.
Run Code Online (Sandbox Code Playgroud)
有end
属性
This is my first android application and
I am trying to make a funny game,...
Run Code Online (Sandbox Code Playgroud)
小智 5
下面是一个示例,说明在 a 中ellipsize
不使用 deprecated 时如何工作:android:singleLine="true"
ConstraintLayout
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="13sp"
android:ellipsize="end"
android:maxLines="2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="long long long long long long text text text" />
Run Code Online (Sandbox Code Playgroud)
请记住,如果您有一个文本应该位于单行中,则将 更改maxLines
为 1。
归档时间: |
|
查看次数: |
146850 次 |
最近记录: |