首页 > 其他分享 >Android-创建简单登陆界面

Android-创建简单登陆界面

时间:2023-01-04 18:33:40浏览次数:38  
标签:界面 创建 height content width layout Android id android


文章目录

  • ​​1、问题描述​​
  • ​​2、结果展示​​
  • ​​3、具体实现​​
  • ​​4、代码实现​​

1、问题描述

使用android studio 或者其他开发案桌工具,创建一个简易的登陆界面。

2、结果展示

Android-创建简单登陆界面_Text

3、具体实现

对于布局的修改只需要修改xml文件就好了,总体是相对布局,在相对布局里,从上至下,首先是头像,其次是一个水平方向的线性布局,在线性布局里有TextView,EditText两个控件,再其次仍然是一个水平方向的线性布局,最后是一个button。

4、代码实现

<?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="@drawable/app_bg"
tools:context=".FirstActivity">

<ImageView
android:id="@+id/ivHead"
android:layout_centerHorizontal="true"
android:layout_marginTop="45dp"
android:background="@drawable/lenna"
android:layout_width="70dp"
android:layout_height="70dp"/>

<LinearLayout
android:id="@+id/ll_id"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/ivHead"
android:layout_marginTop="20dp"
>

<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/tvUser"
android:text="用户"
/>

<EditText
android:id="@+id/edUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


<LinearLayout
android:id="@+id/ll_pwd"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_id"
android:layout_marginTop="20dp"
>

<TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:textSize="20sp"
android:id="@+id/tvPassword"
android:text="密码"
/>

<EditText
android:id="@+id/edPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"/>
</LinearLayout>

<Button
android:id="@+id/btnLogin"
android:text="登陆"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_below="@id/ll_pwd"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:background="#a7157c"
android:textColor="@color/white"
android:textSize="20sp" />

</RelativeLayout>


标签:界面,创建,height,content,width,layout,Android,id,android
From: https://blog.51cto.com/u_14597003/5989182

相关文章

  • Idea安装并创建Flutter
    开发工具IntelliJIDEA2022.2.4(UltimateEdition)Build#IU-222.4459.24,builtonNovember22,2022 安装插件Flutter、Dart的插件 下载flutter的SDKhttps:......
  • android本地文件处理的一些经验
    选择文件后,现在一般返回UricontentResolver.getType(selUrl)结果如下.txttext/plain.jpegimage/jpeg.mp4video/mp4.mp3audio/mpeg.yml/.hprofapp......
  • 获取Android设备系统apk
    前提条件是:电脑adb连接Android设备打开命令好窗口,输入指令adbshell"dumpsyswindow|grepmCurrentFocus"输入指令adbshell"pmpath包名",获取Apk所在目录位置,如:/pr......
  • MySQL event事件,定时按年份动态创建表
    参考资料:1、MySQL事件(定时任务):https://blog.51cto.com/u_15549234/5138457;2、mysql创建存储过程语法(MySQL创建存储过程sql语句):https://www.gaojipro.com/a/108616;3、my......
  • 【抽奖系统】2.数据表创建
    数据表的创建用户表CREATETABLE`bld_lucky_user`(`id`bigintNOTNULL,`username`varchar(50)CHARACTERSETutf8mb4COLLATEutf8mb4_german2_ciNOTNULL......
  • day53 -数据库表的创建,修改与删除,数据表的类型
    创建数据库表 --AUTO_INCREMENT自增--字符串使用单引号括起来--PRIMARYKEY主键,一般一个表只有一个唯一的主键CREATETABLEIFNOTEXISTS`student`(......
  • 【AGC】在AGC平台无法创建应用问题
     关于AGC平台无法创建应用问题。问题背景:cp反馈在AGC平台尝试添加android应用程序,但它只显示web。iOS和Android已禁用。报错截图:​解决方案:检查账户是否已实名认证。......
  • App ui界面布局基本原则
     页面布局顾名思义就是对页面的文字、图形或表格进行排布、设计。优秀的布局,需要对页面信息进行完整的考虑。即要考虑用户需求、用户行为,也要考虑信息发布者的目的、目......
  • android基础02-广播、持久化、权限、ContentProvider
    广播Android中的每个应用程序都可以对自己感兴趣的广播进行注册,这样该程序就只会收到自己所关心的广播内容,这些广播可能是来自于系统的,也可能是来自于其他应用程序的。......
  • Linux下动、静态库的创建和调用
    静态库linux静态库命名规则:静态库的创建准备工作:以一个简单的计算器demo为例,首先建立并书写以下三个文件:Math.h声明四则基本运算#ifndef__MATH_H__#define_......