Android studio|登录页面设计——okhttp登录并返回用户头像

按照老师的要求做了个简陋的登录界面,实现用户登录并获取头像的功能。因为本人完全是个小白,做下来踩了不少坑,这里记录一下,之后遇到类似情况方便处理。

这里只实现了安卓的部分,服务器的东西没有涉及。

参考的部分文章:

《第一行代码》

https://blog.csdn.net/hxy19971101/article/details/76177408?locationNum=3&fps=1

https://blog.csdn.net/kuankuan199308153614/article/details/103260721

先展示一下成品:首先是基本的登录界面,有账号和密码两个输入框和一个登录按钮,初始头像显示灰色,其他的组件没有派上什么用场。在没有输入用户名或者密码的情况下、输入的用户名或密码不正确的情况下弹窗提示。如果输入正确的用户名和头像,显示登录成功,并返回用户的头像:

 

 

 

 

 

 

 

 

 布局主要使用相对布局。目前我认为相对布局的重点就是给每个组件命名,放新组件的时候写清楚新组件在之前哪个组件的上下左右就好了。第一次写,命名有点乱七八糟,之后会慢慢改规范。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    android:background="@drawable/login_background"
    tools:context=".LoginActivity">

    <ImageView
        android:id="@+id/login_logo"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:layout_marginTop="50dp"
        android:gravity="center_horizontal"
        android:src="@drawable/login_logo"/>

    <ImageView
        android:id="@+id/login_ima"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_below="@id/login_logo"
        android:layout_marginTop="30dp"
        android:layout_centerHorizontal="true"
        android:src="@drawable/login_old_ima"/>
  • 3
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值