android 动态添加组件(RadioGroup 添加RadioButton和其他组件的一些问题)
来源:互联网 发布:帮助记忆的软件 编辑:程序博客网 时间:2024/05/16 07:13
android动态添加组件,在项目中会经常使用到,首先罗列一下是我自己遇到的一些问题及解决办法
一、 曾经遇到一个问题解决了好久,(RadioGroup 添加RadioButton和其他组件),当RadioGroup动态添加非RadioButton时有时该组件的宽度会默认为wrapcontent,即使你使用了matchparent。
此时我们可以把宽度设为定值,避免其自动wrap
RadioGroup rg = new RadioGroup(getContext());rg.setOrientation(LinearLayout.VERTICAL);//垂直方向ViewGroup.LayoutParams rg_lp = new ViewGroup.LayoutParams(600, RadioGroup.LayoutParams.WRAP_CONTENT);//rg的宽度设值为600,确定的值rg.setLayoutParams(rg_lp);LinearLayout.LayoutParams lp_et = new LinearLayout.LayoutParams(600, 100);//et的长宽设置final EditText et = new EditText(getContext());et2.setLayoutParams(lp_et2);rg.addView(rb);rg.addView(et);
此时,edittext的长度将为600个像素,长度可控,不再自适应。
1 0
- android 动态添加组件(RadioGroup 添加RadioButton和其他组件的一些问题)
- 动态添加RadioGroup组件的RadioButton出现多选状况解决
- android 动态添加组件出现的一些问题
- android中radioGroup动态添加radioButton
- Dialog中存在radiogroup动态添加radiobutton的ID问题
- Android组件 单项选择(RadioGroup和RadioButton)
- RadioGroup中动态添加RadioButton
- android动态添加组件
- 【Android】动态添加组件
- android动态添加组件
- CheckBox 组件和 RadioGroup RadioButton组件
- Android AlertDialog动态添加组件和padding靠边问题
- Android 代码中动态为RadioGroup添加RadioButton
- Android学习笔记七:基本视图组件:RadioGroup和RadioButton
- RadioGroup动态添加RadioButton,RadioButton设置默认选中第一个,点击其他的RadioButton第一个不再选中,第一个不再选中
- RadioGroup动态添加RadioButton,并且获得事件
- RadioGroup动态添加RadioButton,并且获得事件
- RadioGroup动态添加RadioButton,并且获得事件
- DOM事件对象(addEventListener())
- 热修复 RocooFix
- android获取textview的行数
- maven(6)------maven坐标分析
- opticalflow + openCV
- android 动态添加组件(RadioGroup 添加RadioButton和其他组件的一些问题)
- windows x64下安装RabbitMQ
- 罗振宇跨年演讲精华版:2017年小心这五只黑天鹅
- 在windows下搭建SVN服务器
- 正确安装cocoaPods
- spring配置问题
- H265关于RTP封包
- ckeditor中去掉p标签
- 关系型数据库和非关系型数据库的区别2