Android小程序实现简易QQ界面

 更新时间:2020年05月22日 16:53:55   作者:adorable_  
这篇文章主要为大家详细介绍了Android小程序实现简易QQ界面,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了Android实现简易QQ界面的具体代码,供大家参考,具体内容如下

要求:

(1)与QQ界面控件数目、样式相同
(2)与QQ的图形化界面相同
(3)实现一个简单的点击事件

具体实现:

(1)编写程序代码

package com.example.login;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity extends Activity {
 //声明组件 
 private EditText username;
 private EditText password;
 private Button login;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  //无标题设置
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.activity_main);


  //初始化控件,根据Id获取组件对象
  username = (EditText)findViewById(R.id.username);
  password = (EditText)findViewById(R.id.password);
  login = (Button)findViewById(R.id.login);

  //注册监听
  login.setOnClickListener(new OnClickListener() {

   @Override
   public void onClick(View v) {
    // 登录
    Log.i("tag", "username:"+username.getText().toString());
    Log.i("tag", "password:"+password.getText().toString());
    Toast t1 = Toast.makeText(getApplicationContext(), "登录成功", Toast.LENGTH_LONG);
    t1.show();  
   }
  });
 }
}

(2)对应布局文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@drawable/aa"
 android:orientation="vertical" >

 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#55000000"
  android:orientation="vertical"
  android:paddingLeft="30dp"
  android:paddingRight="30dp" >

  <LinearLayout
   android:layout_marginTop="80dp"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:gravity="center_vertical"
   android:orientation="horizontal" >

   <ImageView
    android:layout_width="43dp"
    android:layout_height="43dp"
    android:src="@drawable/qq" />

   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="QQ"
    android:textColor="#fff"
    android:textSize="50dp" />
  </LinearLayout>

  <EditText
   android:id="@+id/username"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginTop="30dp"
   android:background="@null"
   android:hint="QQ号/手机号/邮箱"
   android:maxLength="13"
   android:singleLine="true"
   android:textColor="#fff"
   android:textSize="30px"
   android:textColorHint="#eee" />

  <View
   android:layout_width="match_parent"
   android:layout_height="1px"
   android:layout_marginTop="10dp"
   android:background="#eee" />

  <EditText
   android:id="@+id/password"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginTop="10dp"
   android:background="@null"
   android:hint="密码"
   android:inputType="textPassword"
   android:maxLength="13"
   android:singleLine="true"
   android:textColor="#fff"
   android:textSize="30px"
   android:textColorHint="#eee" />

  <View
   android:layout_width="match_parent"
   android:layout_height="1px"
   android:layout_marginTop="10dp"
   android:background="#eee" />

  <Button
   android:id="@+id/login"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginTop="10dp"
   android:background="@drawable/button_login_bg"
   android:text="登录"
   android:textColor="#fff"
   android:textSize="25px" />

  <LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_marginTop="10dp"
   android:orientation="horizontal" >

   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="忘记密码?"
    android:textColor="#cc1CA4DE"
    android:textSize="20dp" />

   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:gravity="right"
    android:text="新用户注册"
    android:textColor="#cc1CA4DE"
    android:textSize="20dp" />
  </LinearLayout>
 </LinearLayout>
</LinearLayout>

(3)效果如下:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • Android Kotlin Flow 冷热流详解

    Android Kotlin Flow 冷热流详解

    在Android开发中,Flow是Kotlin协程库的重要组成部分,用于处理异步数据流,它能够异步生产多个值,类似于RxJava中的Observable,本文介绍Android Kotlin Flow 冷热流,感兴趣的朋友一起看看吧
    2024-11-11
  • Android TextView高级显示技巧实例小结

    Android TextView高级显示技巧实例小结

    这篇文章主要介绍了Android TextView高级显示技巧,结合实例形式总结分析了Android TextView控件进行文字与图片显示的相关操作技巧,需要的朋友可以参考下
    2016-10-10
  • Android利用ContentProvider读取短信内容

    Android利用ContentProvider读取短信内容

    这篇文章主要为大家详细介绍了Android利用ContentProvider读取短信内容,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-11-11
  • Android开发之保存图片到相册的三种方法详解

    Android开发之保存图片到相册的三种方法详解

    这篇文章主要介绍了Android开发实现的保存图片到相册功能的三种方法,文中的示例代码讲解详细,有一定的参考价值,感兴趣的可以了解一下
    2022-04-04
  • listview与SQLite结合实现记事本功能

    listview与SQLite结合实现记事本功能

    这篇文章主要为大家详细介绍了listview与SQLite结合实现记事本功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-12-12
  • Android利用OpenGLES绘制天空盒实例教程

    Android利用OpenGLES绘制天空盒实例教程

    这篇文章主要给大家介绍了关于Android利用OpenGLES绘制天空盒的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧
    2018-08-08
  • Android编程获取控件宽和高的方法总结分析

    Android编程获取控件宽和高的方法总结分析

    这篇文章主要介绍了Android编程获取控件宽和高的方法,结合实例形式对比总结并分析了Android控件属性的相关操作技巧,需要的朋友可以参考下
    2016-01-01
  • Android中listview和imageview实现条目单选效果

    Android中listview和imageview实现条目单选效果

    这篇文章主要为大家详细介绍了Android中listview和imageview实现条目单选效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-02-02
  • Android实现打开本地pdf文件的两种方式

    Android实现打开本地pdf文件的两种方式

    在现代应用中,PDF格式因其跨平台、稳定性好、展示内容一致等特点,在Android平台上,如何高效地打开本地PDF文件,不仅关系到用户体验,也直接影响到应用的功能丰富度,本文将给大家详细介绍了Android打开本地pdf文件的两种方式,需要的朋友可以参考下
    2025-04-04
  • Android Dialog 对话框详解及示例代码

    Android Dialog 对话框详解及示例代码

    本文主要介绍Android Dialog,这里详细介绍Android Dialog的基本使用方法,并提供了示例代码和实现效果图,有需要的小伙伴可以参考下
    2016-08-08

最新评论