Increase/Change checkbox size in android using XML

How to create custom bigger text check box with android:scaleX=”” and android:scaleY=””.

In this tutorial we are adding these two attributes on CheckBox to increase their height and width android:scaleX=”” and android:scaleY=”” inside activity_main.xml file. So here is the complete step by step tutorial for Increase/Change checkbox size in android using XML.

android-project-download-code-button

How to Increase/Change checkbox size in android using XML.

Code for MainActivity.java file.

 package com.changecheckboxsize_android_examples.com;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity {

 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 }
}

Code for activity_main.xml layout file.

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context="com.changecheckboxsize_android_examples.com.MainActivity" >

 <TextView
 android:id="@+id/textView1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentTop="true"
 android:layout_centerHorizontal="true"
 android:text="CheckBox with Normal Size"
 android:textAppearance="?android:attr/textAppearanceLarge" />

 <CheckBox
 android:id="@+id/checkBox1"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_below="@+id/textView1"
 android:layout_centerHorizontal="true"
 android:layout_marginTop="22dp"
 android:text="CheckBox" />

 <TextView
 android:id="@+id/textView2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_below="@+id/checkBox1"
 android:layout_centerHorizontal="true"
 android:layout_marginTop="23dp"
 android:text="CheckBox with Increase Size"
 android:textAppearance="?android:attr/textAppearanceLarge" />

 <CheckBox
 android:id="@+id/checkBox2"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_below="@+id/textView2"
 android:layout_marginTop="21dp"
 android:layout_centerHorizontal="true"
 android:text="CheckBox"
 android:scaleX="1.4"
 android:scaleY="1.4" />

</RelativeLayout>

Screenshot:

Increase/Change checkbox size in android using XML

Click here to download Increase/Change checkbox size in android using XML project with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *