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)效果如下:

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

(0)

相关推荐

  • Android使用ViewDragHelper实现仿QQ6.0侧滑界面(一)

    QQ是大家离不开的聊天工具,方便既实用,自从qq更新至6.0之后,侧滑由原来的划出后主面板缩小变成了左右平滑,在外观上有了很大的提升,于是我就是尝试理解下里面的各种逻辑,结合相关资料,研究研究. 知道这里面的一个主要类是ViewDragHelper,那么首先我们要先来了解一下这个ViewDragHelper类,正所谓打蛇打七寸,我们就先来看看官方文档怎么介绍的,有什么奇特的功能. 首先继承: java.lang.Object android.support.v4.widget.ViewDragH

  • android 通过向viewpage中添加listview来完成滑动效果(类似于qq滑动界面)

    文件名:page.xml 复制代码 代码如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="fill_parent"    android:layout_height="fill

  • Android QQ新用户注册界面绘制

    先看看效果图: 问题: 1.下拉列表(因为还没看到这里...) 2.标题栏显示问题 3.按钮的 Enable 设置 .......... 以下是代码: 布局 fragment_main(问题1) <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layo

  • Android仿QQ、微信聊天界面长按提示框效果

    先来看看效果图 如何使用 示例代码 PromptViewHelper pvHelper = new PromptViewHelper(mActivity); pvHelper.setPromptViewManager(new ChatPromptViewManager(mActivity)); pvHelper.addPrompt(holder.itemView.findViewById(R.id.textview_content)); 使用起来还是很简单的 首先new一个PromptViewH

  • Android ListView自定义Adapter实现仿QQ界面

    PS:listview中有一些简单使用的适配器,如:SimpleAdapter:构造方法SimpleAdapter(Context context,List<Map<String,?>> data,reString [] from,int [] to),但这种适配器过于单调,往往不能达到用户想要的效果,想要随心所欲,就用到了BaseAdapter,自定义适配器. 如图: 1.首先写布局文件 activity_layout.xml <?xml version="1.0

  • Android仿QQ空间动态界面分享功能

    先看看效果: 用极少的代码实现了 动态详情 及 二级评论 的 数据获取与处理 和 UI显示与交互,并且高解耦.高复用.高灵活. 动态列表界面MomentListFragment支持 下拉刷新与上拉加载 和 模糊搜索,反复快速滑动仍然非常流畅. 缓存机制使得数据可在启动界面后瞬间加载完成. 动态详情界面MomentActivity支持 (取消)点赞.(删除)评论.点击姓名跳到个人详情 等. 只有1张图片时图片放大显示,超过1张则按九宫格显示. 用到的CommentContainerView和Mom

  • Android QQ登录界面绘制代码

    先看看效果图: 首先过程中碰到的几个问题: 1.对 EditText 进行自定义背景 2.运行时自动 EditText 自动获得焦点 3.在获得焦点时即清空 hint ,而不是输入后清空 4.清空按钮的出现时机(在得到焦点并且有输入内容时) ---  这些问题都有一一解决 --- 以下是代码: 布局 fragment_main(问题2) <!-- android:focusable="true" android:focusableInTouchMode="true&qu

  • Android使用ViewDragHelper实现QQ6.X最新版本侧滑界面效果实例代码

    (一).前言: 这两天QQ进行了重大更新(6.X)尤其在UI风格上面由之前的蓝色换成了白色居多了,侧滑效果也发生了一些变化,那我们今天来模仿实现一个QQ6.X版本的侧滑界面效果.今天我们还是采用神器ViewDragHelper来实现. 本次实例具体代码已经上传到下面的项目中,欢迎各位去star和fork一下. https://github.com/jiangqqlmj/DragHelper4QQ FastDev4Android框架项目地址:https://github.com/jiangqqlm

  • Android实现QQ登录界面遇到问题及解决方法

    先给大家炫下效果图: 首先过程中碰到的几个问题: 1.对 EditText 进行自定义背景 2.运行时自动 EditText 自动获得焦点 3.在获得焦点时即清空 hint ,而不是输入后清空 4.清空按钮的出现时机(在得到焦点并且有输入内容时) ......... --- 这些问题都有一一解决 --- 以下是代码: 布局 fragment_main(问题2) <!-- android:focusable="true" android:focusableInTouchMode=&

  • Android应用中使用ViewPager实现类似QQ的界面切换效果

    这几天在研究ViewPager,简单的写一下如何使用ViewPager实现类似于QQ的"最近联系人.好友.群组"的界面切换(不知道他们是不是用这个方法实现的). ViewPager已经在android-sdk中加入了,具体的位置在%android_sdk_home%\android-compatibility\v4,%android_sdk_home%是你的android-sdk-windows目录. 好,下面放一张效果图: 步骤一:新建一个工程,我的是Viewpager 步骤二:导入

随机推荐