加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 08:16:49 所属栏目:百科 来源:网络整理
导读:UI基础控件综合案例之案例介绍及案例分析 XML ?xml version="1.0" encoding="utf-8"? LinearLayout xmlns:android = "http://schemas.android.com/apk/res/android" android:layout_width = "match_parent" android:layout_height = "match_parent" android:

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


XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" >

    <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" />

    <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#2dff0000" android:orientation="vertical" >

        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" >

            <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="姓名" />

            <EditText  android:id="@+id/et_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="请输入姓名" />
        </LinearLayout>

        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="horizontal" >

            <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="性别" />

            <RadioGroup  android:id="@+id/rg_sex" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" >

                <RadioButton  android:id="@+id/rb_man" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="男" />

                <RadioButton  android:id="@+id/rb_woman" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="女" />
            </RadioGroup>
        </LinearLayout>

        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="horizontal" >

            <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="喜好" />

            <CheckBox  android:id="@+id/cb_hot" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="辣" />

            <CheckBox  android:id="@+id/cb_fish" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="海鲜" />

            <CheckBox  android:id="@+id/cb_sour" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="酸" />
        </LinearLayout>

        <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:gravity="center_vertical" android:orientation="horizontal" >

            <TextView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="预算" />

            <TextView  android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="right" android:text="0元" />

            <SeekBar  android:id="@+id/sb_price" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="3" android:max="100" />

            <TextView  android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="100元" />
        </LinearLayout>

        <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="寻找商品" />
    </LinearLayout>

    <LinearLayout  android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="#3d00ff00" android:orientation="vertical" >

        <ImageView  android:id="@+id/iv_pic" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="3" android:src="@drawable/ic_launcher" />

        <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="显示信息" />
    </LinearLayout>

</LinearLayout>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读