Android登录界面的实现代码分享

本文分享了一个Android登录界面的实现过程,包括用户名和密码输入框的监听、清除按钮的显示逻辑以及密码可见与不可见的切换功能。通过示例代码,展示了如何创建基本的登录界面。
摘要由CSDN通过智能技术生成

最近由于项目需要,宝宝好久没搞Android啦,又是因为项目需要,现在继续弄Android,哎,说多了都是泪呀,别的不用多说,先搞一个登录界面练练手,登录界面可以说是Android项目中最常用也是最基本的,如果这个都搞不定,那可以直接去跳21世纪楼啦。

废话不多说,先上效果图了,如果大家感觉还不错,请参考实现代码吧。

相信这种渣渣布局对很多人来说太简单啦,直接上布局:




















MainActivity如下:

package com.example.logindemo;
import android.support.v7.app.ActionBarActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androi

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个Android登陆界面背景的代码示例: ``` <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/background_image" android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/background_image"/> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" android:textSize="30sp" android:textColor="@android:color/white" android:layout_marginTop="100dp" android:layout_gravity="center_horizontal"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Username" android:textColorHint="@android:color/white" android:background="@android:color/transparent" android:textColor="@android:color/white" android:padding="15dp" android:layout_marginTop="50dp"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Password" android:textColorHint="@android:color/white" android:background="@android:color/transparent" android:textColor="@android:color/white" android:padding="15dp"/> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Login" android:textColor="@android:color/white" android:background="@drawable/button_background" android:layout_marginTop="50dp" android:padding="15dp"/> </LinearLayout> </RelativeLayout> ``` 在这个示例中,我们使用了一个RelativeLayout来包含一个ImageView和一个LinearLayout。ImageView用于设置背景图像,LinearLayout中包含了登陆表单的其他元素。 我们使用了一个带有背景图像的ImageView,该图像是一个drawable资源文件。我们使用LinearLayout来包含登陆表单的其他元素,包括一个标题、两个EditText用于输入用户名和密码,以及一个登陆按钮。 我们还设置了EditText和Button的背景为透明,以便它们与背景图像融合在一起。我们还为按钮设置了自定义背景,以使其在背景图像上更加醒目。 请注意,这只是一个示例代码,你可以根据自己的需求进行修改和定制。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值