题
我有很多 RadioButton
s在我的应用程序。该单选按钮是太大了我。是否有任何办法可以让他们小?
解决方案
不能进行,单选按钮是一个内置的控制部件,因此它的大小是固定的。
其他提示
一个快速哈克溶液是按比例绘制的按钮向下:
<RadioButton
android:scaleX="0.5"
android:scaleY="0.5" />
这伟大工程会更小。
有关要大,这趋向于从容器视图引起一些削波,所以你可能会有硬编码RadioGroup中的高度/宽度以适应缩放按钮。该按钮可绘制也得到明显像素化你去较大,所以如果你想要的东西,3倍大...
这不是真的很棒它的可以来进行,但并不那么简单设置Layout_Width和Layout_height与EditTexts,按钮等要修改的尺寸/像一个复选框/单选按钮使用的图的样子的“背景”和‘按钮’属性来指定自己的可绘制。
这是一个较旧的页面,以及现在的位置是不同的,但是这会给你一个想法: http://www.anddev.org/tutorial_change_look_of_checkbox-t4553.html
可以使用scaleX和scaleY属性,然后使用translationX和translationY把它在单选按钮的窗口。
<RadioButton
android:id="@+id/rbtnfkilo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:scaleX="1.4"
android:scaleY="1.4"
android:text="Kilogram"
android:textColor="#fff"
android:textSize="18sp"
android:translationX="24dp" />
我relpaced RadioButton
与 ToggleButton
和应用同样的风格。我没有复盖的背景,并按钮。
<ToggleButton
android:id="@+id/btnToggle1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1"
android:checked="true"
style="@style/ToggleButtonStyle"
android:button="@null"
android:textOn="@string/btnTitle"
android:textOff="@string/btnTitle"/>
和风格:
<style name="ToggleButtonStyle">
<item name="android:background">@drawable/background_radiobutton</item>
<item name="android:textColor">@color/selector_text_radiobutton</item>
<item name="android:textAppearance">@null</item>
</style>
为我工作-看起来相同,但用定义的高度。
如果你选择按钮是在RadioGroup,你会需要定制的侦听、检查 问题:如何获得radiogroup与togglebuttons?
<RadioGroup android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:checkedButton="@+id/first">
<RadioButton android:id="@+id/first"
android:width="50dp"
android:height="50dp"
android:button="@drawable/button_radio"/>
<RadioButton android:id="@+id/second"
android:width="50dp"
android:height="50dp"
android:button="@drawable/button_radio"/>
<RadioButton android:id="@+id/third"
android:width="50dp"
android:height="50dp"
android:button="@drawable/button_radio"/>
<RadioButton android:id="@+id/fourth"
android:width="50dp"
android:height="50dp"
android:button="@drawable/button_radio"/>
</RadioGroup>
我已经通过调整单选按钮本身
的TEXTSIZE这样做像这样
android:textSize="20sp"
然后应用到我的代码;
<RadioGroup
android:id="@+id/checkboxRadioButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rb1"
style="@android:style/Widget.CompoundButton.CheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/checkBoxMargin"
android:text="YES"
android:textSize="20sp" />
...
希望这有助于有人
不隶属于 StackOverflow