Question

in the below xml code i show CheckBox it appear as larger than it s normal size.But on the other xml codes it looks fine.

 <?xml version="1.0" encoding="utf-8"?>                                                 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dip"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_bg_provide_shadow"
    android:padding="@dimen/padding_small" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/dialog_back_gradient"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1_hiddenactivity"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="You have disabled Mobile Data in the settings.An app is trying to use it.Do you want to allow?"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#40342c" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#000000"
            android:orientation="vertical"
            android:padding="10dip" >

            <CheckBox
                android:id="@+id/checkBox1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#ffffff"
                android:clickable="false"
                android:text="Ashis Sharma " />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dip" >

            <TextView
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1.0" />

            <Button
                android:id="@+id/enable_data_yes"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/small_ok_selector" />

            <Button
                android:id="@+id/enable_data_no"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dip"
                android:background="@drawable/small_cancel_selector" />

            <TextView
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1.0" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Was it helpful?

Solution

create two image like this :

name as check and check1

check

check1

create now xml file in drawable folder

name : checkbox.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check1" android:state_checked="true"/>
<item android:drawable="@drawable/check" android:state_checked="false"/> 
</selector>

and repalce your xml file code :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="20dip"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/rounded_bg_provide_shadow"
    android:padding="@dimen/padding_small" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/dialog_back_gradient"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/textView1_hiddenactivity"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:paddingLeft="10dip"
            android:paddingRight="10dip"
            android:paddingTop="10dip"
            android:text="You have disabled Mobile Data in the settings.An app is trying to use it.Do you want to allow?"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:textColor="#40342c" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#ffffff"
            android:orientation="horizontal"
            android:padding="10dip" >

            <CheckBox
                android:id="@+id/checkBox1"
                android:layout_width="15dp"
                android:layout_height="15dp"
                android:button="@drawable/checkbox"
                android:checked="true"
                android:text=" " />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="Ashis Sharma"
                android:textSize="12dp" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dip" >

            <TextView
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1.0" />

            <Button
                android:id="@+id/enable_data_yes"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/small_ok_selector" />

            <Button
                android:id="@+id/enable_data_no"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dip"
                android:background="@drawable/small_cancel_selector" />

            <TextView
                android:layout_width="0dip"
                android:layout_height="wrap_content"
                android:layout_weight="1.0" />
    </LinearLayout>
    </LinearLayout>
    </LinearLayout>

final output :

enter image description here

OTHER TIPS

   <?xml version="1.0" encoding="utf-8"?>                                                 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_margin="20dip"
    android:background="@android:color/transparent"
    android:gravity="center"
    android:orientation="vertical" >

 <LinearLayout
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background="@drawable/rounded_bg_provide_shadow"
 android:padding="@dimen/padding_small" >

 <LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/dialog_back_gradient"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1_hiddenactivity"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:paddingLeft="10dip"
        android:paddingRight="10dip"
        android:paddingTop="10dip"
        android:text="You have disabled Mobile Data in the settings.An app is trying to use it.Do you want to allow?"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#40342c" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:orientation="vertical"
        android:padding="10dip" >

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="40dp"
            android:layout_height="40dp"
            android:background="#ffffff"
            android:clickable="false"
            android:text="Ashis Sharma " />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="5dip" >

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.0" />

        <Button
            android:id="@+id/enable_data_yes"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/small_ok_selector" />

        <Button
            android:id="@+id/enable_data_no"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dip"
            android:background="@drawable/small_cancel_selector" />

        <TextView
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="1.0" />
    </LinearLayout>
    </LinearLayout>
    </LinearLayout>

Try this in check box give your size manually..

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top