我用
appMusicTab.setButtonDrawable(R.drawable.all);
设置 RadioButton 的按钮样式,
但是drawable总是在RadioGroup的左侧,如何在代码中为“按钮”设置左填充?谢谢!!
我试过了
appMusicTab.setPadding(20, 0, 0, 0);
和:
appMusicTab.setLeft(20);
但那些不起作用。
这是我的代码:
RadioButton appMusicTab = new RadioButton(mContext);
appMusicTab.setText(tabInfo.name);
appMusicTab.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 25);
appMusicTab.setGravity(Gravity.CENTER);
appMusicTab.setId(tabInfo.id);
// appMusicTab.setButtonDrawable(android.R.color.transparent);
appMusicTab.setButtonDrawable(R.drawable.all);
appMusicTab.setBackgroundResource(R.drawable.app_tab_bg);
appMusicTab.setPadding(30, 0, 0, 0);
RadioGroup.LayoutParams lp =
new RadioGroup.LayoutParams(
RadioGroup.LayoutParams.MATCH_PARENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
lp.bottomMargin =MASettings.MAIN_UI_APP_TAB_MARGIN_BOTTOM;
mAppsTab.addView(appMusicTab, lp); //mAppsTab is a RadioGroup