Android项目开发基础

本文介绍使用AndroidStudio开发酒店预约入住功能的过程,涵盖线性布局、属性设置及文本输入组件的使用,适合初学者了解Android应用开发的基础知识。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

学习Android方面的相关知识,这是新的知识点,用到了新的开发工具Android Studio ,这跟之前的HTML的布局用的属性是不相同的,同时又有了许多需要记忆的方法和属性。这次学习的是酒店的预约入住功能,总体来说还是相对有难度,有许多新的知识点需要记住。

学习新的知识点,从最简单的开始(登录页面) :

android:orientation= “” 在Android Studio 开发工具里是指定线性布局的方向,有vertical
(直线垂直),和horizontal(水平方向垂直)
容器里需要设置android:layout_width=“match_parent” 和android:layout_height=“wrap_content”
宽和高可以设置的属性有自定义的和match_parent(最大),wrap_content(根据内容大小改变)

在visual studio 里开发时文字直接可以在div里写 需要回填数据一般在input里,现在Android开发文字选用TextView标签写在 android:text=""(如android:text=“手机号”) 填写框则用EditText标签

现在使用最简单的页面布局代码是:


<?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">
    <!--  android:orientation 指定线性布局的方向  -->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

    <TextView
        android:layout_width="70dp"
        android:layout_height="wrap_content"
        android:text="手机号">
    </TextView>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </EditText>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView
            android:layout_width="70dp"
            android:layout_height="wrap_content"
            android:text="验证码">

        </TextView>
        <EditText
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="获取验证码"/>
    </LinearLayout>

    <Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="登录"/>
</LinearLayout>

结果如下:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值