Android shape实现控件圆角,背景,边框等属性

接下来就是shape的讲解:

[html] view plain copy

  1.   
  2.     android:shape="rectangle"  
  3.     >  
  4.       
  5.       
  6.       
  7.       
  8.       
  9.       
  10.       
  11.       
  12.       
  13.       
  14.       
  15.       
  16.        
  17.       
  18.       
  19.       
  20.       
  21.       
  22.       
  23.  

 

 

shape_rectangle_button.xml代码:

[html] view plain copy

  1.   
  2.     android:shape="rectangle"  
  3.     >  
  4.     
  5.         android:radius="10dip"  
  6.         />  
  7.     
  8.         android:color="#8DEEEE"  
  9.         />  
  10.     
  11.         android:width="250dip"  
  12.         android:height="25dip"  
  13.         />  
  14.     
  15.         android:width="2dip"  
  16.         android:color="#000000"  
  17.         />  
  18.  

 

shape_oval_button.xml代码:

 

[html] view plain copy

  1.   
  2.     android:shape="oval"  
  3.     >  
  4.     
  5.         android:radius="10dip"  
  6.         />  
  7.     
  8.         android:color="#787878"  
  9.         />  
  10.     
  11.         android:width="300dip"  
  12.         android:height="50dip"  
  13.         />  
  14.     
  15.         android:width="2dip"  
  16.         android:color="#000000"  
  17.         />  
  18.   
  19.  

shape_layout.xml代码:

[html] view plain copy

  1.   
  2.     android:shape="rectangle"  
  3.     >  
  4.     
  5.         android:radius="10dip"  
  6.         />  
  7.     
  8.         android:startColor="#FFC0CB"  
  9.         android:centerColor="#FF83FA"  
  10.         android:endColor="#CAFF70"  
  11.         android:angle="90"        
  12.         />  
  13.       
  14.  

activity_main.xml代码:

[html] view plain copy

  1.     xmlns:tools="http://schemas.android.com/tools"  
  2.     android:layout_width="match_parent"  
  3.     android:layout_height="match_parent"  
  4.     android:orientation="vertical"  
  5.     android:background="@drawable/shape_layout"  
  6.     tools:context=".MainActivity" >  
  7.       
  8.     
  9.         android:layout_width="match_parent"  
  10.         android:layout_height="wrap_content"  
  11.         android:orientation="vertical"  
  12.         >  
  13.             
  14.                 android:layout_width="wrap_content"  
  15.                 android:layout_height="wrap_content"  
  16.                 android:text="按钮:"  
  17.                 android:textSize="25sp"  
  18.                 />  
  19.             
  20.                 android:layout_width="wrap_content"  
  21.                 android:layout_height="wrap_content"  
  22.                 android:text="@string/no_changed"  
  23.                 />  
  24.             
  25.                 android:layout_width="wrap_content"  
  26.                 android:layout_height="wrap_content"  
  27.                 android:layout_marginTop="10dip"  
  28.                 android:text="@string/changed_rectangle"  
  29.                 android:background="@drawable/shape_rectangle_button"  
  30.                 />  
  31.             
  32.                 android:layout_width="wrap_content"  
  33.                 android:layout_height="wrap_content"  
  34.                 android:layout_marginTop="10dip"  
  35.                 android:text="@string/changed_oval"  
  36.                 android:background="@drawable/shape_oval_button"  
  37.                 />        
  38.           
  39.           
  40.         
  41.             android:layout_width="match_parent"  
  42.             android:layout_height="match_parent"  
  43.             android:layout_marginTop="20dip"  
  44.             android:orientation="vertical"  
  45.             >  
  46.             
  47.                 android:layout_width="wrap_content"  
  48.                 android:layout_height="wrap_content"  
  49.                 android:text="输入框:"  
  50.                 android:textSize="25sp"  
  51.                 />  
  52.             
  53.                 android:layout_width="wrap_content"  
  54.                 android:layout_height="wrap_content"  
  55.                 android:layout_marginTop="10dip"  
  56.                 android:hint="@string/no_changed"  
  57.                 />  
  58.             
  59.                 android:layout_width="wrap_content"  
  60.                 android:layout_height="wrap_content"  
  61.                 android:layout_marginTop="10dip"  
  62.                 android:hint="@string/changed_rectangle"  
  63.                 android:background="@drawable/shape_rectangle_edittext"  
  64.                 />             
  65.       
  66.  

详细地址:http://blog.csdn.net/joker_ya/article/details/38638481

你可能感兴趣的:(Android shape实现控件圆角,背景,边框等属性)