場景 Android佈局管理器-從實例入手學習相對佈局管理器的使用: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103838924 線性佈局LinearLayout,分為水平和垂直線性佈局。 實現效果如下 註: 博客: htt ...
場景
Android佈局管理器-從實例入手學習相對佈局管理器的使用:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103838924
線性佈局LinearLayout,分為水平和垂直線性佈局。
實現效果如下
註:
博客:
https://blog.csdn.net/badao_liumang_qizhi
關註公眾號
霸道的程式猿
獲取編程相關電子書、教程推送與免費下載。
實現
將activity修改為LinearLayout佈局
並且通過
android:orientation="vertical"
設置其為豎直線型佈局。
然後添加兩個輸入框分別為用戶名和密碼
通過
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>