如何在java代码中将按钮宽度设置为android中的wrap_content或match_parent [英] how to set button width to the wrap_content or match_parent in the android from java code
本文介绍了如何在java代码中将按钮宽度设置为android中的wrap_content或match_parent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在java代码中设置android 中的wrap_content或match_parent的按钮宽度?
how to set button width to the wrap_content or match_parent in the android from java code?
推荐答案
使用以下方法:
Use the following method:
Button myButton = (Button) findViewById(R.id.buttonid);
LayoutParams buttonparam = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT,1.0f);
myButton.setLayoutParams(buttonparam);
LayoutParams(layout_width,layout_height,layout_weight);
LayoutParams(layout_width,layout_height,layout_weight);
这篇关于如何在java代码中将按钮宽度设置为android中的wrap_content或match_parent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文