学习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>
结果如下: