WRAP_CONTENT不工作的按钮高度的android [英] wrap_content is not working in button height android

查看:112
本文介绍了WRAP_CONTENT不工作的按钮高度的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WRAP_CONTENT不工作的按钮  像这样的:

"wrap_content" is not working in button like this :

 now                        want
_____________
|            |           _____________
|   aaaaaa   |     =>   | aaaaaaaaaaa |
|____________|           --------------

和我的按钮code的XML:

and my button code in xml :

 <Button 
     android:layout_gravity="center"
     android:id="@+id/input_expend"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"                               
     android:textSize="12sp"
     android:text="aaaaaaa"                         
     android:background="@drawable/btn_01"/>
 <Button 
     android:layout_gravity="center"
     android:id="@+id/input_expend"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"                               
     android:textSize="12sp"
     android:text="aaaaaaa"                         
     android:background="@drawable/btn_02"/> 

如何解决这个问题呢?   谢谢!

How to solve this problem? Thanks!

推荐答案

按钮查看安卓了minHeight 属性设置 48dip 默认。您可以设置比你的实际文本AAAAA,如1DP 了minHeight 低。然后 WRAP_CONTENT 将工作。但我不认为这是推荐的。

Button is a View and the android:minHeight attribute is set 48dip default. You can set minHeight lower than your actual text 'aaaaa' such as 1dp. Then wrap_content will work. But I don't think this is recommended.

这篇关于WRAP_CONTENT不工作的按钮高度的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆