Android開發,實現一個簡約又好看的登錄頁

文章目錄

    • 1. 編寫布局文件
    • 2.設計要點說明
    • 3. 效果圖
    • 4. 關于作者其它項目視頻教程介紹

1. 編寫布局文件

  • 編寫activity.login.xml 布局文件
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat 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"><RelativeLayoutandroid:layout_width="match_parent"android:layout_height="200dp"android:background="@drawable/gradient_background5"><androidx.appcompat.widget.Toolbarandroid:id="@+id/toolbar"android:layout_width="match_parent"android:layout_height="wrap_content"app:title="登錄"app:titleTextColor="@color/white" /></RelativeLayout><androidx.core.widget.NestedScrollViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="-50dp"><androidx.appcompat.widget.LinearLayoutCompatandroid:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/img_shape_login_bg"android:orientation="vertical"><androidx.appcompat.widget.LinearLayoutCompatandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_margin="30dp"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="歡迎登錄雅居名宿"android:textColor="@color/purple_200"android:textSize="24sp"android:textStyle="bold" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="10dp"android:text="繼續登錄您的賬號!"android:textColor="#BDBDBD"android:textSize="13sp" /><androidx.appcompat.widget.LinearLayoutCompatandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginTop="46dp"android:text="用戶名"android:textColor="#585858" /><EditTextandroid:id="@+id/et_username"android:layout_width="match_parent"android:layout_height="40dp"android:layout_marginTop="6dp"android:background="@drawable/login_et_bg"android:hint="請輸入用戶名"android:paddingLeft="10dp"android:paddingRight="10dp"android:textSize="14sp" /><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:layout_marginTop="16dp"android:text="密碼"android:textColor="#585858" /><EditTextandroid:id="@+id/et_password"android:layout_width="match_parent"android:layout_height="40dp"android:layout_marginTop="6dp"android:background="@drawable/login_et_bg"android:hint="請輸入密碼"android:inputType="textPassword"android:paddingLeft="10dp"android:paddingRight="10dp"android:textSize="14sp" /><CheckBoxandroid:id="@+id/checkbox"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="記住密碼" /><TextViewandroid:id="@+id/btn_login"android:layout_width="match_parent"android:layout_height="50dp"android:layout_marginTop="20dp"android:background="@drawable/gradient_background4"android:gravity="center"android:text="登錄"android:textColor="#ffffff"android:textSize="16dp" /><androidx.appcompat.widget.LinearLayoutCompatandroid:id="@+id/btn_register"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:layout_marginTop="20dp"><TextViewandroid:layout_width="wrap_content"android:layout_height="30dp"android:layout_gravity="center"android:gravity="center"android:text="還沒有賬號?"android:textColor="#747481"android:textSize="13sp" /><TextViewandroid:layout_width="wrap_content"android:layout_height="30dp"android:layout_gravity="center"android:gravity="center"android:text=" 注冊"android:textColor="@color/purple_200"android:textSize="13sp" /></androidx.appcompat.widget.LinearLayoutCompat></androidx.appcompat.widget.LinearLayoutCompat></androidx.appcompat.widget.LinearLayoutCompat></androidx.appcompat.widget.LinearLayoutCompat></androidx.core.widget.NestedScrollView></androidx.appcompat.widget.LinearLayoutCompat>
  • 在res/drawable創建頂部漸變背景 gradient_background5.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><gradientandroid:startColor="@color/purple_200"android:endColor="#BBCEE9"android:angle="270"android:type="linear"/></shape>
  • 在res/drawable創建登錄按鈕背景 gradient_background4.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle"><gradientandroid:startColor="#0066f5"android:endColor="#A9C0E7"android:angle="45" /><cornersandroid:bottomLeftRadius="10dp"android:topRightRadius="10dp" /></shape>
  • 在res/drawable創建登錄區域背景 img_shape_login_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"><solid android:color="@color/white"/><cornersandroid:topLeftRadius="15dp"android:topRightRadius="15dp" /></shape>

2.設計要點說明

  1. 父布局使用LinearLayoutCompat線性布局包裹
  2. 自適應小屏幕使用NestedScrollView包裹,在使用NestedScrollView時,特別注意它的子組件只能有且僅有一個
  3. 使用shape來實現背景圓角,漸變等設置

3. 效果圖

在這里插入圖片描述

4. 關于作者其它項目視頻教程介紹

  1. Android新聞資訊app實戰:https://www.bilibili.com/video/BV1CA1vYoEad/?vd_source=984bb03f768809c7d33f20179343d8c8
  2. Androidstudio開發購物商城實戰:https://www.bilibili.com/video/BV1PjHfeXE8U/?vd_source=984bb03f768809c7d33f20179343d8c8
  3. Android開發備忘錄記事本實戰:https://www.bilibili.com/video/BV1FJ4m1u76G?vd_source=984bb03f768809c7d33f20179343d8c8&spm_id_from=333.788.videopod.sections
  4. Androidstudio底部導航欄實現:https://www.bilibili.com/video/BV1XB4y1d7et/?spm_id_from=333.337.search-card.all.click&vd_source=984bb03f768809c7d33f20179343d8c8
  5. Android使用TabLayout+ViewPager2實現左右滑動切換:https://www.bilibili.com/video/BV1Mz4y1c7eX/?spm_id_from=333.337.search-card.all.click&vd_source=984bb03f768809c7d33f20179343d8c8

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/81067.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/81067.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/81067.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

機器學習:【拋擲硬幣的貝葉斯后驗概率】

首先,拋硬幣的問題通常涉及先驗概率、似然函數和后驗概率。假設用戶可能想通過觀察一系列的正面(H)和反面(T)來更新硬幣的偏差概率。例如,先驗可能假設硬幣是均勻的,但隨著觀察到更多數據,用貝葉斯定理計算后驗分布。 通常,硬幣的偏差可以用Beta分布作為先驗,因為它…

Echarts 問題:自定義的 legend 點擊后消失,格式化 legend 的隱藏文本樣式

文章目錄 問題分析實現步驟代碼解釋問題 如下圖所示,在自定義的 legend 點擊后會消失 分析 我把隱藏的圖例字體顏色設為灰色,可以借助 legend.formatter 和 legend.textStyle 結合 option.series 的 show 屬性來達成。以下是具體的實現步驟和示例代碼: <!DOCTYPE ht…

光譜相機如何提升目標檢測與識別精度

光譜相機&#xff08;多光譜/高光譜&#xff09;通過捕捉目標在多個波段的光譜特征&#xff0c;能夠揭示傳統RGB相機無法感知的材質、化學成分及物理特性差異。以下是提升其目標檢測與識別精度的核心方法&#xff1a; ?1. 硬件優化&#xff1a;提升數據質量? ?(1) 光譜分辨…

springboot項目配置nacos,指定使用環境

遇到這樣一個問題&#xff0c;在開發、測試、生成環境之間切換的問題。 大多數的操作是通過修改spring.profiles.active來確定指向使用的環境配置文件&#xff0c;對應項目中需要增加對應的配置文件。 但是現在幾乎所有公司都會有代碼管理不管是SVN、git&#xff0c;這樣就會涉…

AI代碼審查的落地實施方案 - Java架構師面試實戰

AI代碼審查的落地實施方案 - Java架構師面試實戰 本文通過模擬一位擁有十年Java研發經驗的資深架構師馬架構與面試官之間的對話&#xff0c;深入探討了AI代碼審查的落地實施方案。 第一輪提問 面試官&#xff1a; 馬架構&#xff0c;請介紹一下您對AI代碼審查的理解。 馬架…

TDengine 訂閱不到數據問題排查

簡介 TDengine 在實際生產應用中&#xff0c;經常會遇到訂閱程序訂閱不到數據的問題&#xff0c;總結大部分都為使用不當或狀態不正確等問題&#xff0c;需手工解決。 查看服務端狀態 通過 sql 命令查看有問題的 topic 和consumer_group 組訂閱是否正常。 select * from inf…

二、UI自動化測試02--元素定位方法

目錄 一、定位?組元素?法二、XPath 定位?法1. 路徑策略1.1 路徑值獲取?法 2. 利?元素屬性策略利?元素屬性策略的注意事項 3. 屬性和邏輯結合4. 層級和屬性結合策略5. XPath 延伸?法 三、CSS 定位?法1. CSS 策略: id選擇器/class選擇器/元素選擇器/屬性選擇器2. 屬性選擇…

HotSpot的算法細節

可達性分析算法 以一系列“GC Roots”根對象作為起始節點集&#xff0c;從這些節點開始&#xff0c;根據引用關系向下搜索&#xff0c;搜索過程所走過的路徑稱為“引用鏈”&#xff08;Reference Chain&#xff09;&#xff0c;如果某個對象到GC Roots間沒有任何引用鏈相連&am…

Transformer數學推導——Q27 證明時序注意力(Temporal Attention)在視頻模型中的幀間依賴建模

該問題歸類到Transformer架構問題集——注意力機制——跨模態與多模態。請參考LLM數學推導——Transformer架構問題集。 在視頻理解任務中&#xff0c;捕捉幀與幀之間的時間依賴關系&#xff08;如動作的連貫性、物體的運動軌跡&#xff09;是核心挑戰。時序注意力&#xff08…

服務器和數據庫哪一個更重要

在當今數字化的時代&#xff0c;服務器和數據庫都是構建和運行各種應用系統的關鍵組成部分&#xff0c;要說哪一個更重要&#xff0c;其實很難簡單地給出定論。 服務器就像是一個強大的引擎&#xff0c;為應用程序提供了穩定的運行環境和高效的計算能力。它負責接收和處理來自…

【Android】四大組件之Service

目錄 一、什么是Service 二、啟停 Service 三、綁定 Service 四、前臺服務 五、遠程服務擴展 六、服務保活 七、服務啟動方法混用 你可以把Service想象成一個“后臺默默打工的工人”。它沒有UI界面&#xff0c;默默地在后臺干活&#xff0c;比如播放音樂、下載文件、處理…

pytest 技術總結

目錄 一 pytest的安裝&#xff1a; 二 pytest有三種啟動方式&#xff1a; 三 用例規則&#xff1a; 四 配置框架&#xff1a; 一 pytest的安裝&#xff1a; pip install pytest # 安裝 pip install pytest -U # 升級到最新版 二 pytest有三種啟動方式&#xff1a; 1…

redis 有序集合zrange和zrangebyscore的區別

起因是查詢數據&#xff0c;用了zrangebyscore 但是一直顯示沒數據 具體命令zrangebyscore key 0 -1 withscores, 原有印象中一直是這么用的&#xff0c;但是突然查不出來了&#xff0c; 于是搜了下問題所在。 通過分數查看 不能用0和-1表示最小和最大&#xff0c;只能用分數來…

Tableau 基礎表制作

目錄 1.數據連接 2. 數據可視化 3. 基礎表制作 3.1 對比分析&#xff1a;比大小 1. 柱狀圖 2. 條形圖 3. 熱力圖 4. 氣泡圖 5. 詞云 3.2 變化分析&#xff1a;看趨勢 1. 折線圖 2. 面積圖 3.3 構成分析&#xff1a;看占比 1. 餅圖 2. 樹地圖 3. 堆積圖 3.4 關…

反序列化漏洞1

一、PHP類與對象 1. 類 概念理解: 類是共享相同結構和行為的對象的集合&#xff0c;可以理解為特征的提取。例如將耳朵長、尾巴短、紅眼睛、吃胡蘿卜、蹦跳行走的動物特征抽象為"兔子"類。代碼結構: 使用class關鍵字定義類類名遵循大駝峰命名法包含成員變量(屬性)和…

為什么要對 ACI 網絡進行升級?

一、硬件演進 1. 交換機接口 前面板接口由 1/10G 升級至 10/25/100G fabric 上行鏈路 40G 升級至 100/400G 2. 交換機角色 交換機可以是 spine 或者 leaf,而不是固定角色 3. EOS APIC-SERVER-M2/L2 2024年6月30日 EOS,替換設備為 APIC-SERVER-M4/L4 二、網絡升級參考文…

DeepSeek+Cline:開啟自動化編程新紀元

目錄 一、引言&#xff1a;AI 編程時代的曙光二、認識 DeepSeek 和 Cline2.1 DeepSeek 是什么2.2 Cline 詳解2.3 兩者結合的魅力 三、DeepSeek Cline 安裝與配置全流程3.1 安裝 VS Code3.2 安裝 Cline 插件3.3 獲取 DeepSeek API Key3.4 配置 Cline 與 DeepSeek 連接 四、實戰演…

【展位預告】正也科技將攜營銷精細化管理解決方案出席中睿營銷論壇

在醫藥行業面臨政策深化、技術迭代、全球化競爭的多重挑戰下&#xff0c;第二屆中睿醫藥健康生態生長力峰會暨第三十五屆中睿醫藥營銷論壇將于廣州盛大啟幕。5月19-20日本次峰會以“聚焦政策變革、把握產業趨勢、構建生態共贏”為核心&#xff0c;旨在通過全產業鏈資源整合與創…

【深度學習】評估模型復雜度:GFLOPs與Params詳解

評估模型復雜度&#xff1a;GFLOPs與Params詳解 在深度學習模型設計與優化過程中&#xff0c;GFLOPs和Params是論文中兩個重要的評估指標&#xff0c;它們分別衡量模型的計算復雜度和參數量。本文將詳細介紹這兩個概念及其在實踐中的應用。 1. Params&#xff1a;模型參數量 …