菜鸟的博客

纵有疾风起,人生不言弃。

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

安卓的基本布局

相对布局管理器:在一个参考点的四周(上,下,左,右)布局的管理器,即位置都是相对的。

线性布局管理器:分为水平和垂直两种,垂直较为常用,垂直布局相和横格纸类似。

帧布局管理器(这个不常用):在帧布局管理中,每加入一个组件,都将创建一个空白的区域,通常称为帧,这些帧都会根据gravity属性执行自动对齐。默认情况下,帧布局从屏幕的左上角(0,0)坐标点开始布局,多个组件层叠排序,后面的组件覆盖前面的组件。

表格布局管理器和网格布局管理器较为类似,两者都呈格子布局。不过网格布局较为灵活。

登录界面的代码编写

复制代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!--第一行-->
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="20dp"
        android:hint="@string/text1"
        android:drawableLeft="@mipmap/zhanghao"
        android:inputType="text"
        />
    <!--第二行-->
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="20dp"
        android:hint="@string/text2"
        android:drawableLeft="@mipmap/mima"
        android:inputType="textPassword"
        android:autofillHints="password"
        />
    <!--第三行-->
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/text3"
        android:textColor="#FFFFFF"
        android:background="#FF009688"/>
    <!--第四行-->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/text4"
        android:gravity="center_horizontal"
        android:paddingTop="20dp"/>
</LinearLayout>
复制代码

 

posted on   hhmzd233  阅读(23)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示