【问题标题】:Radio button size in androidandroid中的单选按钮大小
【发布时间】:2011-09-01 11:36:24
【问题描述】:

如何使用 java 代码减小 android 中的单选按钮大小?它太大了。

我正在使用代码:

deal = new RadioButton(context);
deal.setHeight(10);
deal.setWidth(5);

这根本没有效果。请提出建议。

【问题讨论】:

    标签: android


    【解决方案1】:

    您是否正在动态创建单选按钮。然后,您可以使用layoutparams,而不是使用setheightsetwidth 方法设置高度和宽度。在layout params中设置宽高...下面是按钮设置参数的例子..

    addQuestion = new Button(NewEmirContext);
    
    addQuestion.setId(134);
    addQuestion.setTag("addQuestion");
    addQuestion.setBackgroundDrawable(getResources().getDrawable(R.drawable.add_button));
    addQuestion.setGravity(Gravity.LEFT);
    LinearLayout.LayoutParams addQuestion_Params = 
        new LinearLayout.LayoutParams(24, 24);  
    addQuestion_Params.leftMargin=20;
    addQuestion.setOnClickListener(mirScreenClickListener);
    questionAndAddButtonContainer.addView(addQuestion, addQuestion_Params);
    

    【讨论】:

    • 我使用 param.topMargin=20;但是改变单选按钮之间的间隙没有效果。哪里不对了?谢谢。
    猜你喜欢
    • 2017-10-15
    • 1970-01-01
    • 1970-01-01
    • 2019-01-18
    • 2014-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多