Android开发-Android APP实操-1.项目创建及启动页面UI编码

news/发布时间2024/5/16 10:14:33

一、项目创建及模拟器安装

1.选择新建一个project

2. 选择空模板

3.完成新project的设置

 下载完成后点击Finish

4.下载安卓模拟器

 选择Pixel7

点击下载R

 为虚拟机命名,选择竖屏,点击Finish.

5.点击启动,测试运行

 运行成功!

 

二、启动页面UI编码

 1.打开MainActivity.java文件,Ctrl+左键进入activity_main.xml

 

 

2.在activity_main.xml中点击右键,进入xml编写UI页面模式

 

 

3.修改activity_main.xml的代码,识别手写xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"tools:context=".MainActivity"></RelativeLayout>

 

4.AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"><applicationandroid:allowBackup="true"android:dataExtractionRules="@xml/data_extraction_rules"android:fullBackupContent="@xml/backup_rules"android:icon="@mipmap/ic_launcher"android:label="@string/app_name"android:roundIcon="@mipmap/ic_launcher_round"android:supportsRtl="true"android:theme="@style/Theme.MyApplication1"tools:targetApi="31"><activityandroid:name=".MainActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity></application></manifest>

 

activity_main:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="@mipmap/ic_launcher"tools:context=".MainActivity"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:paddingLeft="44dp"android:paddingRight="44dp"android:layout_alignParentBottom="true"android:layout_marginBottom="90dp"><Buttonandroid:layout_alignParentLeft="true"android:layout_width="100dp"android:layout_height="50dp"android:text="@string/login"android:textSize="20sp"android:textColor="#ffffff"android:background="@drawable/shape_login_btn"/><Buttonandroid:layout_alignParentRight="true"android:layout_width="100dp"android:layout_height="50dp"android:text="@string/register"android:textSize="20sp"android:textColor="#ffffff"android:background="@drawable/shape_register_btn"/></RelativeLayout></RelativeLayout>

 

strings.xml:

<resources><string name="app_name">MyApplication1</string><string name="login">登录</string><string name="register">注册</string>
</resources>

shape_login_btn.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><corners android:radius="9dp" /><solid android:color="#c75fe768" />
</shape>

shape_register_btn.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><corners android:radius="9dp" /><solid android:color="#c75fe768" />
</shape>

 

 

5.启动运行

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.ulsteruni.cn/article/25183387.html

如若内容造成侵权/违法违规/事实不符,请联系编程大学网进行投诉反馈email:xxxxxxxx@qq.com,一经查实,立即删除!

相关文章

c# 嵌入锐浪报表

1、从锐浪官网上下载安装文件,然后直接安装 ; 2、打开VS2019,添加引用,选中COM项下的:Grid++Report Engine 6 Type Library 6.0 然后,在VS解决方案资源管理器中,打开”引用“,在gregn6lib上点键,点击属性,将独立设置为True,将嵌入式互操作类型设置为True。 3、打开…

Java进阶 - [1-4] 反射

一、类加载区别 当我们刚接触java语言的时候,我们最常见的代码应该就是初始化某个对象,然后调用该对象的方法。 1、使用new创建对象,返回对象的引用。Student student = new Student(); 2、调用方法:student.say();当我们想在运行期才能指定具体对象的类型或调用的某个方法…

GitHub WebHook 使用教程

介绍 GitHub WebHook 的使用方式,GitHub 允许我们配置 WebHook ,它允许我们配置某个仓库发生某个事件时,通知指定的外部服务。本文收录于 Github.com/niumoo/JavaNotes,Java 系列文档,数据结构与算法! 本文收录于网站:https://www.wdbyte.com/,我的公众号:程序猿阿朗什…

2-14. 生成 ListView 列表

修改 ItemEditor 加载 ItemDataList_SO老师在调试的过程中发现,AssetDatabase.FindAssets 里面不需要加t:加载 ItemDetails测试 打开 Editor 窗口,然后就能看到有打印输出查看示例文档最终要的是实现 makeItem 和 bindItem。前者是列表中添加项目时候调用,后者是点击项目的时…

[转帖]重磅硬核|一文聊透对象在JVM中的内存布局等(一)

https://ost.51cto.com/posts/14747 大家好,我是bin,又到了每周我们见面的时刻了,我的公众号在1月10号那天发布了第一篇文章?《从内核角度看IO模型的演变》,在这篇文章中我们通过图解的方式以一个C10k的问题为主线,从内核角度详细阐述了5种IO模型的演变过程,以及两种IO线…