Android的按键布局与大文本大小 [英] Android Button layout with big text size
本文介绍了Android的按键布局与大文本大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使具有相同高度两个相同的按钮,但是当文本太长(第二个按钮),然后打破标记。我怎样才能解决这个问题?
XML布局:
<?XML版本=1.0编码=UTF-8&GT?;< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =match_parent> <的LinearLayout
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent> <按钮 机器人:文字=测试
机器人:layout_height =100dp
机器人:layout_width =0dp
机器人:layout_weight =1/> <按钮
机器人:填充=0dp
机器人:文字=动脉紧张风波
机器人:layout_height =100dp
机器人:layout_width =0dp
机器人:layout_weight =1/> < / LinearLayout中>< / LinearLayout中>
解决方案
添加机器人:单线=真正的
<的LinearLayout
机器人:layout_height =WRAP_CONTENT
机器人:layout_width =match_parent> <按钮
机器人:单线=真 机器人:文字=测试
机器人:layout_height =100dp
机器人:layout_width =0dp
机器人:layout_weight =1/> <按钮
机器人:单线=真
机器人:填充=0dp
机器人:文字=动脉紧张风波
机器人:layout_height =100dp
机器人:layout_width =0dp
机器人:layout_weight =1/> < / LinearLayout中>
I'm trying to make two identical buttons with the same height, but when the text is too long (the second button) then breaks markup. How can I fix it?
xml layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:text="test"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"/>
<Button
android:padding="0dp"
android:text="Arterial tension disturbance"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
解决方案
Add android:singleLine="true"
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent">
<Button
android:singleLine="true"
android:text="test"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"/>
<Button
android:singleLine="true"
android:padding="0dp"
android:text="Arterial tension disturbance"
android:layout_height="100dp"
android:layout_width="0dp"
android:layout_weight="1"/>
</LinearLayout>
这篇关于Android的按键布局与大文本大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文