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>
相關文章
相關標籤/搜索