Android:以编程方式覆盖Button minheight

编程入门 行业动态 更新时间:2024-10-28 08:30:34
本文介绍了Android:以编程方式覆盖Button minheight的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Searching how to reduce the padding inside my buttons, I found out in stackoverflow/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

本文发布于:2023-11-06 09:33:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563322.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   Android   minheight   Button

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!