天天看點

Android仿qq登陸界面

每天登陸qq,就想着自己做一個qq登陸界面,下了一個qq.apk, 解壓之後拿到裡面的圖檔資源,就開始動工了。建立一個項目,将資源全部copy到自己的資源目錄下!

嘗試将自己qq資料清除,在登陸之前有一個彩色qq界面,

Android仿qq登陸界面

這個界面隻是停留兩秒左右,是以`

public class LoadActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            startActivity(new Intent(LoadActivity.this, MainActivity.class));
            finish();

        }
    },1000);


}

Handler handler = new Handler();
           

}`

發一個延時handler啟動activity就可以了,然後将自身finish(),在這裡引導頁就沒有做了。

在登陸界面的布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#110080ff"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="#330080ff"

        android:orientation="vertical">

        <ImageView
            android:id="@+id/login_icon"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:layout_gravity="center"
            android:layout_marginBottom="30dp"
            android:layout_marginTop="50dp"
            android:src="@mipmap/login_icon" />

    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <EditText
            android:id="@+id/name"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#ffffffff"
            android:hint="QQ号/手機号/郵箱"
            android:paddingLeft="20dp"
            android:textColor="#ff000000"
            android:textSize="14sp" />

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="#11000000" />

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#ffffffff"
            android:hint="密碼"
            android:paddingLeft="20dp"
            android:textColor="#ff000000"
            android:textSize="14sp" />


    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:gravity="center">

        <Button
            android:id="@+id/login_button"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="@drawable/shape"
            android:gravity="center"
            android:text="登 陸"
            android:textColor="#ffffffff"
            android:textSize="16sp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:gravity="bottom">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:layout_weight="1"
            android:layout_margin="5dp"
            android:id="@+id/non"
            android:text="無法登陸?" />

        <TextView
            android:id="@+id/news"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_gravity="bottom|right"
            android:gravity="left"
            android:text="新使用者" />
    </LinearLayout>


</LinearLayout>
           
Android仿qq登陸界面

初始化`

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }
           
private void init(){
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.login_icon);
    loginIcon = (ImageView) findViewById(R.id.login_icon);
    loginIcon.setImageDrawable(new CircleImageDrawable(bitmap));
    mNon = (TextView)this.findViewById(R.id.non);
    mNon.setOnClickListener(this);
    mNews = (TextView)this.findViewById(R.id.news);
    mNews.setOnClickListener(this);
    mName = (EditText)this.findViewById(R.id.name);
    mPassWord = (EditText)this.findViewById(R.id.password);
    mName.addTextChangedListener(mNameTextWatcher);
    mPassWord.addTextChangedListener(mPasswordTextWatcher);

    mLoginButton = (Button)this.findViewById(R.id.login_button);
    mLoginButton.setOnClickListener(this);
}`
           

這樣就可以了