場景
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>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/41505.html
標籤:Android
