移动到屏幕上时,TextView的数据超过了其大小向右 [英] The Screen moves to right when TextView data exceeds its size
问题描述
我有我在其中显示客户的详细信息的UI。现在有些客户地址很长,当我在TextView中显示它的地址的TextView的结束,因此参数的一些方向上的全屏幕布局的变化得到隐藏。我怎能地址TextView的修复程序的长度。我想这样的事情与ellipsize但没有运气。
<样式名称=CustomerTextView>
<项目名称=机器人:layout_width>&FILL_PARENT LT; /项目>
<项目名称=机器人:layout_height>&WRAP_CONTENT LT; /项目>
<项目名称=机器人:TEXTSIZE>&10SP LT; /项目>
<项目名称=机器人:文字颜色> @android:彩色/白色< /项目>
<项目名称=机器人:layout_margin>&5DP LT; /项目>
<项目名称=机器人:背景> @绘制/ textview_border< /项目>
<项目名称=机器人:ellipsize>结束< /项目>
< /风格>
和为客户地址我的XML文件看起来像这样
<的TableRow安卓重力=右> <的TextView
风格=@风格/ CustomerLabelTextView
机器人:重力=右
机器人:文字=@字符串/ customerAddress/>
< /&的TableRow GT; <的TableRow
机器人:重力=右>
<的TextView
机器人:ID =@ + ID / customerAddress
风格=@风格/ CustomerTextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =1.0
机器人:重力=右/> < /&的TableRow GT;
您可以使用的android:maxEms
,的android:最大长度
或安卓了maxWidth
在布局来控制宽度你的的TextView
。您还可以使用的android:MAXLINES
来控制线的的TextView
将采取的数量。我已经添加了maxEms线到你的TextView的声明。
<的TextView
机器人:ID =@ + ID / customerAddress
风格=@风格/ CustomerTextView
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:layout_weight =1.0
机器人:maxEms =25
机器人:重力=右/>
I have a UI in which I show details of the customers. Now some customer address are long and when I display it in the TextView the full screen layout shifts in the direction of the end of the address Textview and hence some of the parameters get hidden. How can i keep the length of the address textview fix. I tried something like this with ellipsize but no luck.
<style name="CustomerTextView">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">10sp</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:layout_margin">5dp</item>
<item name="android:background">@drawable/textview_border</item>
<item name ="android:ellipsize">end</item>
</style>
and my XML file for the customer address looks like this
<TableRow android:gravity="right" >
<TextView
style="@style/CustomerLabelTextView"
android:gravity="right"
android:text="@string/customerAddress" />
</TableRow>
<TableRow
android:gravity="right" >
<TextView
android:id="@+id/customerAddress"
style="@style/CustomerTextView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:gravity="right" />
</TableRow>
You can use android:maxEms
, android:maxLength
or android:maxWidth
in your layout to control the width of your TextView
. You can also use android:maxLines
to control the number of lines your TextView
will take. I have added the maxEms line to your TextView declaration.
<TextView
android:id="@+id/customerAddress"
style="@style/CustomerTextView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:maxEms="25"
android:gravity="right" />
这篇关于移动到屏幕上时,TextView的数据超过了其大小向右的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!