UI基础控件综合案例之XML布局编写

前端之家收集整理的这篇文章主要介绍了UI基础控件综合案例之XML布局编写前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

UI基础控件综合案例之案例介绍及案例分析


  1. XML
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >
  4.  
  5. <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#2dffff00" android:text="选餐Start!" android:textColor="@color/blueviolet" android:textSize="25sp" android:textStyle="bold|italic" android:typeface="monospace" />
  6.  
  7. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#2dff0000" android:orientation="vertical" >
  8.  
  9. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" >
  10.  
  11. <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓名" />
  12.  
  13. <EditText android:id="@+id/et_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入姓名" />
  14. </LinearLayout>
  15.  
  16. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="horizontal" >
  17.  
  18. <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="性别" />
  19.  
  20. <RadioGroup android:id="@+id/rg_sex" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >
  21.  
  22. <RadioButton android:id="@+id/rb_man" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="男" />
  23.  
  24. <RadioButton android:id="@+id/rb_woman" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" />
  25. </RadioGroup>
  26. </LinearLayout>
  27.  
  28. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" >
  29.  
  30. <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="喜好" />
  31.  
  32. <CheckBox android:id="@+id/cb_hot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="辣" />
  33.  
  34. <CheckBox android:id="@+id/cb_fish" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="海鲜" />
  35.  
  36. <CheckBox android:id="@+id/cb_sour" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="酸" />
  37. </LinearLayout>
  38.  
  39. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="horizontal" >
  40.  
  41. <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预算" />
  42.  
  43. <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="right" android:text="0元" />
  44.  
  45. <SeekBar android:id="@+id/sb_price" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:max="100" />
  46.  
  47. <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="100元" />
  48. </LinearLayout>
  49.  
  50. <Button android:id="@+id/btn_find" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:background="@color/blueviolet" android:text="寻找商品" />
  51. </LinearLayout>
  52.  
  53. <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#3d00ff00" android:orientation="vertical" >
  54.  
  55. <ImageView android:id="@+id/iv_pic" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="3" android:src="@drawable/ic_launcher" />
  56.  
  57. <ToggleButton android:id="@+id/tb_click" android:layout_width="match_parent" android:layout_height="0dp" android:layout_margin="5dp" android:layout_weight="1" android:background="@color/blueviolet" android:textOff="下一个" android:textOn="显示信息" />
  58. </LinearLayout>
  59.  
  60. </LinearLayout>

猜你在找的XML相关文章