zoukankan      html  css  js  c++  java
  • 2月3日学习内容

    今天看了学习安卓的视频,看了Button和EditText看完视频后,又将视频中老师所讲的代码自己敲写了一遍;有颇大的收获;

    <Button/>

    Button(继承TextView

    1、文字大小、颜色<Button    id/width/hight/text书写内容/textsize字体大小/textcolor文字 颜色/background按钮背景颜色   />

    2、自定义背景形状:在drawable下新建一个Drawable resource file  (shape)

    <solid  android:color=”填充整个按钮颜色”/>

    <corners  android:radius=”10dp”/>按钮为圆角

    <stroke  android:width=”1dp”  android:color=”描边的颜色”/>描边

    <corners  android:radius=”10dp”/>按钮为圆角

    3、自定义按压效果

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:andriod="http://schemas.android.com/apk/res/android">
        <item andriod:state_pressed="true">
        <shape>
            <solid andriod:color="#FF7F500A"/>
            <corners andriod:radius="5dp"/>圆角
        </shape>
        </item>
        <item andriod:state_pressed="false">
            <shape>
                <solid andriod:color="#FF9900"/>
                <corners andriod:radius="5dp"/>
            </shape>
        </item>
    </selector>

     

    4、点击事件

    Android:onclick=”方法名方法名要在.java里面声明,写上函数

    Public void 方法名(View view){

    Toast.makeText(this,”我被点击了”,Toast.LENGTH_SHORT).show();

    }

    ettext=(Button)findViewById(R.id.et_login);
    ettext.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(EditTextActivity.this, "登陆成功!", Toast.LENGTH_SHORT).show();
        }
    });

    EditText:主要是制作登录界面,用到了上面的点击事件。

    1、常用属性

    <EditText   android:hint=”用户名”  android:inputType=”number”显示数字键盘  />

    <EditText   android:hint=”密码”   android:inputType=”textPassword”  />显示小黑圆点

    EditText的声明

     

    username=(EditText)findViewById(R.id.ed_1);
    username.addTextChangedListener(new TextWatcher() {

     

    2、监听事件

    3、制作登录界面

  • 相关阅读:
    python 装饰器
    python 环境迁移之requirements.txt (window环境)
    selenium 元素查找与属性
    pytest+allure(allure-pytest基于这个插件)设计定制化报告
    Capability配置
    python_excel
    python_连接mysql
    MySql_1
    appium_环境搭建
    appium_appium简介
  • 原文地址:https://www.cnblogs.com/1234yyf/p/12257129.html
Copyright © 2011-2022 走看看