AbsoluteLayout绝对布局 实现登录界面

本文介绍了Android中使用XML布局文件设置子组件绝对位置的方法,通过`android:layout_x`和`android:layout_y`属性指定组件在屏幕上的坐标,展示了如何创建一个简单的登录界面,包括用户名和密码输入框以及登录按钮的位置设定。
摘要由CSDN通过智能技术生成

android:layout_x=“20dp” 用于指定该子组件的x轴坐标
android:layout_y="20dp"用于指定该子组件y轴坐标
xml 文件

<?xml version="1.0" encoding="utf-8"?>


<!-- 定义文本框使用绝对定位 -->

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="60dp"
    android:layout_y="60dp"
    android:text="用户名" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="120dp"
    android:layout_y="45dp"
    android:width="200px" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="60dp"
    android:layout_y="160dp"
    android:text="密  码" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="120dp"
    android:layout_y="145dp"
    android:password="true"
    android:width="200px" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="130dp"
    android:layout_y="235dp"
    android:text="登    录" />

java 文件
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.basolutelayout);
// setContentView(R.layout.attributelayout);
}
界面
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值