Android:以编程方式覆盖Button minheight [英] Android : overriding Button minheight programmatically

查看:106
本文介绍了Android:以编程方式覆盖Button minheight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索如何减少按钮内部的填充,我在 https://stackoverflow.com/a/20323723/3888000中找到了,我应该将xml文件中按钮的最小高度设置为0dp. 是的,它对我有用.

Searching how to reduce the padding inside my buttons, I found out in https://stackoverflow.com/a/20323723/3888000 that I should set the min-height of my button to 0dp in the xml file. And yes, it works for me.

问题是:我想以编程方式创建我的按钮,而setMinimumHeight(1)和setMinHeight(1)均无效. 怎么做?

Problem is : I want to create my button programmatically, and neither setMinimumHeight(1) nor setMinHeight(1) did work. How to do it ?

顺便问一下,这两种方法有什么区别?

By the way, what is the difference between these two methods ?

谢谢!

推荐答案

我认为您应该尝试使用setPadding(0,0,0,0);而是查看是否适合您.

I think you should try using setPadding(0,0,0,0); instead and see if that works for you.

就minHeight与minimumHeight而言,minHeight是可在布局文件中使用的XML属性名称. setMinimumHeight是执行相同操作的相应View API方法.

As far as minHeight vs minimumHeight goes, minHeight is the XML attribute name you can use in a layout file. setMinimumHeight is the corresponding View API method to do the same thing.

这篇关于Android:以编程方式覆盖Button minheight的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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