二、Android平台搭建与简单应用设计

前面我们安装了Android studio应用并简单创建了helloworld项目,下面再来进一步学习,也很简单,学习内容如下:

(1)创建一个简单的项目,输出“你好啊,这是我的第一个安卓项目!”

(2)创建项目,使用表格布局管理器放置组件,界面如下图所示:

 一、创建一个简单的项目,输出“你好啊,这是我的第一个安卓项目!”

这个其实很简单,直接在“activity_main.xml”中修改“TextView”的文本内容就好了,默认是HelloWorld。

然后直接输出:

 二、创建项目,使用表格布局管理器放置组件,界面如下图所示。

只需要设计布局,所以需要在“activity_main.xml”中编写语句就好了,这里选择表格约束,具体代码如下:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="手  机  号:"
        android:textColor="#004"
        android:textSize="17sp"
        android:paddingLeft="16dp"/>
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="请填写手机号码"
        android:paddingLeft="8dp"
        android:selectAllOnFocus="true"/>
</TableRow>
<TableRow>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密        码:"
        android:textColor="#004"
        android:paddingLeft="16dp"
        android:textSize="16sp"/>
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="请填写密码"
        android:paddingLeft="8dp"
        android:selectAllOnFocus="true"/>
</TableRow>
<TableRow>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="确认密码:"
        android:paddingLeft="16dp"
        android:textColor="#004"
        android:textSize="16sp"/>
    <EditText
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:hint="请确定密码"
        android:paddingLeft="8dp"
        android:selectAllOnFocus="true"/>
</TableRow>
<TableRow>
    <TextView
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="取消"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="确认"
        />
</TableRow>

</TableLayout>

然后输出:

over, 这只是简单的界面布局的代码,刚开始尝试去理解下,后面用Java代码添加事件才是难点哦,不过慢慢来总是可以的。

发布了21 篇原创文章 · 获赞 21 · 访问量 9412

猜你喜欢

转载自blog.csdn.net/Until_U/article/details/105124368