Use*_*001 1 android android-layout android-checkbox
在下面的xml代码中,我显示CheckBox它看起来比正常大小更大.但是在其他xml代码上它看起来很好.
<?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>
Run Code Online (Sandbox Code Playgroud)
像这样创建两个图像:
命名为check和check1


在drawable文件夹中创建现在的xml文件
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>
Run Code Online (Sandbox Code Playgroud)
并重新生成您的xml文件代码:
<?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>
Run Code Online (Sandbox Code Playgroud)
最终输出:

| 归档时间: |
|
| 查看次数: |
396 次 |
| 最近记录: |