1
回答
android radiobutton居中问题
百度AI开发者大赛带你边学边开发,赢100万奖金,加群:418589053   
想用java实现对radiogroup里radiobutton的宽高,但是weight、gravity属性设置了无效,下面是代码
if (tabs != null && tabs.size() > 0) {
            for (int i = 0; i < tabs.size(); i++) {

                RadioButton rb = new RadioButton(context);

                rb.setText(tabs.get(i));
                rb.setButtonDrawable(android.R.color.transparent);
                rb.setId(RG_ID_DEFAULT + i);
                rb.setTextColor(getResources().getColorStateList(R.color.black));
                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,
                        LinearLayout.LayoutParams.WRAP_CONTENT,1.0f);
                params.gravity=Gravity.CENTER;
                rb.setLayoutParams(params);
                rgTabs.addView(rb, i);
            }

            rgTabs.invalidate();

        }
举报
deadPool
发帖于2年前 1回/377阅
顶部