霍比特人2国语免费观看:从xml中改变checkBox大小和形状

来源:百度文库 编辑:中财网 时间:2024/04/28 13:46:55

从xml中改变checkBox大小和形状

XMLAndroid

主程序很简单了

  setContentView(R.layout.main);

看一下main

Java代码  
  1.   
  2.     android:orientation="vertical" android:layout_width="fill_parent"  
  3.     android:layout_height="fill_parent">  
  4.   
  5.     
  6.         android:layout_height="wrap_content" android:text="a checkbox" />  
  7.   
  8.     
  9.         android:layout_height="wrap_content" android:text="checked checkbox"  
  10.         android:checked="true" />  
  11.   
  12.   
  13.     
  14.         android:layout_height="wrap_content" android:text="new checkbox"  
  15.         android:background="@drawable/checkbox_background" android:button="@drawable/checkbox" />  
  16.   
  17.     
  18.         android:layout_height="wrap_content" android:text="new checked checkbox"  
  19.         android:checked="true" android:background="@drawable/checkbox_background"  
  20.         android:button="@drawable/checkbox" />  
  21.   
  22.   

 前两个是默认的 一个为选择的 一个是没有选择的

后面两个是改变之后的。

从代码中可以看出来 只有android:background和android:button

drawable/checkbox_background 他是一个xml

Java代码  
  1.   
  2.   
  3.   
  4.       
  5.       
  6.   

 checkbox_label_background是一个9.png图片

drawable/checkbox

Java代码  
  1.   
  2.   
  3.   
  4.     
  5.         android:drawable="@drawable/checkbox_on_background_focus_yellow" />  
  6.           
  7.     
  8.         android:drawable="@drawable/checkbox_off_background_focus_yellow" />  
  9.           
  10.     
  11.         android:drawable="@drawable/checkbox_off_background" />  
  12.       
  13.     
  14.         android:drawable="@drawable/checkbox_on_background" />  
  15.       
  16.   

 

 

  • 桌面.rar (21.8 KB)
  • 下载次数: 280
分享到: