The second experience of android development

预解决问题

questions:
1.	创建项目。
2.	添加各种控件代码。
3.	运行结果显示。
4.	添加“线性布局”等布局。

1. 创建项目。

新建工程,之后在工程里建立模块(某种意义上,一个模块即是一个app):在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
创建成功:在这里插入图片描述

2. 2. 添加添加文本显示框TextView、文本编辑框EditText和按钮Button控件代码

在这里插入图片描述
在这里插入图片描述

布局代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:text="i am textView" />

    <EditText
        android:layout_width="wrap_content"
        android:layout_height="50dp"
        android:text="i am textView" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="i am textView" />

</LinearLayout>

3. 运行结果显示。

在这里插入图片描述
在这里插入图片描述

4. 添加“线性布局”、“表格布局”、“相对布局”、“层布局(帧布局)”查看运行效果。

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


    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="wrap_content">
<!--            垂直线性布局-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_width="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_height="50dp"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_width="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_height="50dp"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_width="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_height="50dp"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_width="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_height="50dp"
                    android:layout_weight="1"/>

            </LinearLayout>
            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="vertical"
                android:layout_height="300dp">
                <Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_height="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_width="match_parent"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_height="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_width="match_parent"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_height="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_width="match_parent"
                    android:layout_weight="1"/>
<Button
                    android:text="热点"
                    android:layout_margin="10dp"
                    android:layout_height="0dp"
                    android:background="@color/custom_cursor_color"
                    android:layout_width="match_parent"
                    android:layout_weight="1"/>


            </LinearLayout>
<!--表格布局-->
            <TableLayout
                android:padding="10dp"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:stretchColumns="1"><!--            设置可被拉伸的列-->

                <TableRow>
                    <Button
                        android:layout_margin="5dp"
                        android:text="user"
                        android:padding="5dp"
                        android:background="#f0f0f0"/>
                    <EditText
                        android:layout_margin="5dp"
                        android:layout_column="1"
                        android:text=""
                        android:padding="5dp"
                        android:background="#f0f0f0"/>
                </TableRow>

                <TableRow>
                    <Button
                        android:text="password"
                        android:padding="5dp"
                        android:layout_margin="5dp"
                        android:background="#f0f0f0"/>
                    <EditText
                        android:layout_margin="5dp"
                        android:text=""
                        android:padding="5dp"
                        android:background="#f0f0f0"/>
                </TableRow>
                <Button
                    android:padding="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="login"
                   />
                <Button
                    android:padding="10dp"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="register"
                   />


            </TableLayout>

<!--     相对布局       -->
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/textView1"
                    android:layout_width="200dp"
                    android:layout_height="90dp"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="20dp"
                    android:layout_marginEnd="20dp"
                    android:layout_marginStart="20dp"
                    android:layout_marginTop="20dp"
                    android:background="@color/custom_cursor_color"
                    android:gravity="center"
                    android:text="文表区"
                    android:textColor="@color/white" />

                <Button
                    android:layout_width="80dp"
                    android:layout_height="50dp"
                    android:text="leftBtn"
                    android:layout_alignLeft="@id/textView1"
                    android:layout_below="@id/textView1" />
                <Button
                    android:layout_width="80dp"
                    android:text="rightBtn"
                    android:layout_below="@id/textView1"
                    android:layout_alignRight="@id/textView1"
                    android:layout_height="50dp"/>
            </RelativeLayout>

            <!--        层布局-->
            <FrameLayout
                android:layout_marginTop="50dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
                <View
                    android:layout_gravity="center"
                    android:layout_width="200dp"
                    android:background="@color/light_blue_600"
                    android:layout_height="200dp"/>
                <View
                    android:layout_gravity="center"
                    android:layout_width="150dp"
                    android:background="@color/white_little"
                    android:layout_height="150dp"/>
                <View
                    android:layout_gravity="center"
                    android:layout_width="100dp"
                    android:background="@color/light_blue_A200"
                    android:layout_height="100dp"/>
                <View
                    android:layout_gravity="center"
                    android:layout_width="50dp"
                    android:background="@color/gradient_end01"
                    android:layout_height="50dp"/>

            </FrameLayout>
        </LinearLayout>



    </ScrollView>

</LinearLayout>

运行效果:

请添加图片描述

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值