
这是我定义textVIEw对象的方法:
<TextVIEw androID:ID="@+ID/priceLast" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_alignParentRight="true" androID:layout_alignParenttop="true" androID:layout_margintop="0dp" androID:gravity="top|right" androID:includeFontpadding="false" androID:paddingBottom="0dp" androID:paddingleft="0dp" androID:paddingRight="0dp" androID:paddingtop="0dp" androID:singleline="true" androID:text="@string/price" androID:textcolor="@color/dark_green" androID:textIsSelectable="false" androID:textSize="24sp" androID:textStyle="bold" />
Root VIEwGroup:
<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:background="@drawable/bg_card_selector" androID:orIEntation="vertical" androID:paddingBottom="8dp" androID:paddingtop="4dp" >解决方法 对于情况#2,原因是在大多数字体中,所有数字具有相同的字符宽度(以像素为单位).因此数字“1”和“8”采用相同数量的宽度像素.原因是你可以在彼此的顶部写数字,数字将始终对齐.这意味着像“4.1”这样的字符串将比“4.8”右边有更多的空像素. 解决方案是使用每个数字具有紧凑宽度的字体,或者使用您自己的视图将数字呈现为位图,找到最右边的非空像素,并移动位图以使其与右对齐. 总结
以上是内存溢出为你收集整理的android – TextView不会粘在右上角全部内容,希望文章能够帮你解决android – TextView不会粘在右上角所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)