Change size of an Android radio button drawable

1.2k Views Asked by At

I have set the image to be used by a radio button using the following code and custom styles and xml.

<RadioButton
android:id="@+id/toolsButton1"
style="@style/sideMenuTab"
android:rotation="180"
android:drawableTop="@drawable/ic_view"
android:text="@string/tools_but1"
android:layout_marginBottom="2dp" >
</RadioButton>

<style name="sideMenuTab" parent="@android:style/Widget.CompoundButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">60dp</item>
<item name="android:padding">15dp</item>
<item name="android:textAllCaps">true</item>
<item name="android:clickable">false</item>
<item name="android:background">@drawable/tab_selector_bg</item>
<item name="android:textColor">@drawable/tab_selector_tx</item>
<item name="android:button">@null</item>
<item name="android:gravity">center</item>
</style>

ic_view.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
      android:drawable="@drawable/icon_eye_green" />
<item android:state_checked="false" android:state_window_focused="false"
      android:drawable="@drawable/icon_eye_black" />

<item android:state_checked="false" android:drawable="@drawable/icon_eye_black" />
<item android:state_checked="true" android:drawable="@drawable/icon_eye_green" />
</selector>

tab_selector_tx.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
      android:color="@color/side_menu_tab_on_tx" />
<item android:state_checked="false" android:state_window_focused="false"
      android:color="@color/side_menu_tab_off_tx" />


<item android:state_checked="false" android:color="@color/side_menu_tab_off_tx" />
<item android:state_checked="true" android:color="@color/side_menu_tab_on_tx" />
</selector>

tab_selector_bg.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_window_focused="false"
      android:drawable="@color/side_menu_tab_on_bg" />
<item android:state_checked="false" android:state_window_focused="false"
      android:drawable="@color/side_menu_tab_off_bg" />


<item android:state_checked="false"      android:drawable="@color/side_menu_tab_off_bg" />
<item android:state_checked="true" android:drawable="@color/side_menu_tab_on_bg" />
</selector>

The icons I am just as the RadioButton as too big and I would prefer to resize them here rather than resize the icons before I bring them into the application.

Is this possible??

It is ok if the solution requires resizing the icons in the code, as I am using the RadioButtons in a custom RadioGroup and I am already resizing the actual button by code.

0

There are 0 best solutions below