Android布局管理器-使用LinearLayout实现简单的登陆窗口布局

场景

Android布局管理器-从实例入手学习相对布局管理器的使用:android

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103838924编程

线性布局LinearLayout,分为水平和垂直线性布局。app

实现效果以下布局

 

 

注:学习

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。spa

实现

将activity修改成LinearLayout布局.net

 

 

而且经过   code

android:orientation="vertical"

设置其为竖直线型布局。xml

而后添加两个输入框分别为用户名和密码blog

经过

android:hint="请输入帐户"

设置输入框提示文本

经过

android:drawableLeft="@drawable/account"

设置输入框左边的图片

这里的图片是放在res下的drawable目录下

 

 

而后添加一个按钮,设置其颜色。

完整示例代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
    tools:context=".LinearLayoutActivity">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="20dp"
        android:hint="请输入帐户"
        android:drawableLeft="@drawable/account"
        />

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="20dp"
        android:hint="请输入密码"
        android:drawableLeft="@drawable/pass"
        />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="登陆"
        android:textColor="#FFFFFF"
        android:background="#FF009688"
        />

</LinearLayout>
相关文章
相关标签/搜索