久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3259|回復: 0
打印 上一主題 下一主題
收起左側(cè)

Android布局管理器及簡單控件的使用

[復制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:856808 發(fā)表于 2020-12-18 23:08 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
layout文件夾的布局文件activity_main.xml中設(shè)計如下登陸界面
           
(1)需將三個drawable文件,需復制到drawable文件夾。
   editext_selector.xml:編輯框的有無焦點時的邊框繪制,引用了下面兩個文件。
   shape_edit_focus.xml:編輯框獲取焦點時的邊框
   shape_edit_normal.xml:編輯框沒有獲取焦點時的獲邊框
2)顏色值文件colors.xml,復制到values文件夾。

(注:這些文件一般自己都有,附件是完整實驗文件夾,可直接打開使用)

MainActivity.java文件:
package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView tv_password;
    private EditText et_password;
    private Button btn_forget;
    private RadioGroup rg_login;
    private CheckBox ck_remember;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //加載布局
        setContentView(R.layout.activity_main);
        //獲取控件
        tv_password = findViewById(R.id.textView4);
        et_password = findViewById(R.id.editText3);
        btn_forget = findViewById(R.id.button5);
        ck_remember = findViewById(R.id.checkBox);
        rg_login = findViewById(R.id.radiogroup);
        //單選按鈕組綁定監(jiān)聽器
        rg_login.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                if (checkedId == R.id.radioButton3) {
                    tv_password.setText("登錄密碼:");
                    et_password.setHint("請輸入密碼");
                    btn_forget.setText("忘記密碼");
                    ck_remember.setVisibility(View.VISIBLE);
                } else if (checkedId == R.id.radioButton4) {
                    tv_password.setText("驗證碼:");
                    et_password.setHint("請輸入驗證碼");
                    btn_forget.setText("獲取驗證碼");
                    ck_remember.setVisibility(View.INVISIBLE);
                }
            }
        });
    }
}


activity_main.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    tools:context=".MainActivity">

    <RadioGroup
        android:id="@+id/radiogroup"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:baselineAligned="false"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/radioButton3"
            android:layout_width="197dp"
            android:layout_height="wrap_content"
            android:text="密碼登錄"
            android:textSize="20sp"
            android:textStyle="bold" />

        <RadioButton
            android:id="@+id/radioButton4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="驗證碼登錄"
            android:textSize="20sp"
            android:textStyle="bold" />
    </RadioGroup>

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

        <TextView
            android:id="@+id/textView2"
            android:layout_width="120dp"
            android:layout_height="35dp"
            android:text="手機號碼:"
            android:textAllCaps="false"
            android:textSize="20sp"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/editText"
            android:layout_width="294dp"
            android:layout_height="50dp"
            android:background="@drawable/editext_selector"
            android:ems="10"
            android:hint="請輸入手機號碼"
            android:inputType="phone" />

    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="53dp">

        <TextView
            android:id="@+id/textView4"
            android:layout_width="120dp"
            android:layout_height="35dp"
            android:text="登錄密碼:"
            android:textSize="20sp"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/editText3"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:background="@drawable/editext_selector"
            android:ems="10"
            android:hint="請輸入密碼"
            android:inputType="textPassword" />

        <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:text="忘記密碼" />

    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="42dp">

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="120dp"
            android:layout_height="42dp"
            android:text="記住密碼"
            android:textSize="15sp" />
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <Button
            android:id="@+id/button6"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="登錄"
            android:textSize="20sp"
            android:textStyle="bold" />
    </TableRow>

</LinearLayout>
布局管理器及簡單控件的使用.rar (8.6 MB, 下載次數(shù): 13)






評分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产综合在线视频 | 成人在线免费观看视频 | 天天操天天舔 | 精品一区二区在线观看 | 北条麻妃国产九九九精品小说 | 一区二区在线看 | 日韩在线一区二区 | 成年视频在线观看福利资源 | 久久久久久久久久久久亚洲 | 日韩中文字幕 | 日韩国产在线观看 | 亚洲国产精品成人久久久 | 欧美视频1区 | 91电影| 午夜视频一区二区三区 | 91久久久久久久久久久久久 | 波多野吉衣久久 | 中文字幕亚洲一区二区va在线 | 久久精品国产99国产精品 | 日韩av手机在线观看 | 久久精品国产一区二区三区 | 欧美 日韩 国产 成人 在线 91 | 天天综合网天天综合 | 91啪影院 | 亚洲一区影院 | 国产精品一区二区三区在线 | 国产日韩精品在线 | 黄色男女网站 | 天天躁人人躁人人躁狂躁 | 亚洲精久久 | 91在线资源| 久久久91精品国产一区二区三区 | 欧美亚洲视频在线观看 | 免费成人高清 | 久久99精品国产麻豆婷婷 | 欧产日产国产精品视频 | 久草青青草 | 黄色免费三级 | 久久大陆| 久久久久久精 | 午夜视频免费在线观看 |