当前位置:首页 » 《随便一记》 » 正文

Android学习_qq_36250569的博客

27 人参与  2022年02月26日 11:43  分类 : 《随便一记》  评论

点击全文阅读


SHAPE:圆角和颜色渐变过度

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">

    <!-- 圆角的半径 -->
    <corners android:radius="20dp"/>

    <!-- 填充颜色 -->
    <gradient
        android:angle="90"
        android:startColor="#5E57D6"
        android:centerColor="#593DBE"
        android:endColor="#5E57D6">

    </gradient>

</shape>

gradient(渐变属性)在shape下进行颜色渐变

startColor:开始颜色

centerColor:中间颜色

endColor:结束颜色

angle:角度

BUTTON焦点触发变化

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!-- 正常状态 -->
    <item android:drawable="@drawable/btn_normal" android:state_pressed="false"/>

    <!-- 按下状态 -->
    <item android:drawable="@drawable/btn_pressed" android:state_pressed="true"/>

</selector>

利用按下数据监测;state_pressed判断真伪

页面跳转

public class MainActivity extends AppCompatActivity {

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

        Button btn = (Button) findViewById(R.id.button2);
        btn .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(MainActivity.this , login.class);
                startActivity(i);
            }
        });
    }
}

通过建立一个新的活动窗口,然后在原窗口的Java程序中添加跳转事件程序

Text View

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

wrap_content        控件大小正好包含里面的内容

fill_parent与match_parent        控件大小与父布局大小一致

字符和int数据类型

字符串转int


a、int i = Integer.parseInt(str);或者int i = Integer.parseInt(str,int i);

b、int i = Integer.valueOf(str).intValue();


int转字符串


String a = Integer.toString(i);

String b = String.valueOf(i);

String c = "" + i;

按键事件弹窗
 

   Intent i = new Intent(MainActivity.this , login.class);
                    startActivity(i);

BUTTON

一、button 监听事件

        Button btn_wechat = (Button) findViewById(R.id.button2);
        btn_wechat .setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                }

二、button onclick事件

XML中添加onclick及名称

alt+Enter creat onclick事件函数

视频播放

android播放视频和视频做背景_红叶岭谷的博客-CSDN博客


点击全文阅读


本文链接:http://zhangshiyu.com/post/35390.html

颜色  事件  渐变  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1