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

Android学习_qq_36250569的博客

15 人参与  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://m.zhangshiyu.com/post/35390.html

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

  • 评论(0)
  • 赞助本站

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

最新文章

  • 老公把上亿豪宅送养妹后,我把人和房都拆了(顾思思顾言洲)全书免费_(顾思思顾言洲)老公把上亿豪宅送养妹后,我把人和房都拆了后续(顾思思顾言洲)
  • 沈星悦傅时安_沈星悦傅时安
  • 离婚后,居然还能以旧换新?(陈汉李淼淼李思)全书浏览_离婚后,居然还能以旧换新?全书浏览
  • 完结文给女团主播狂刷百万反被骂穷逼,我反手送她队友出道列表_完结文给女团主播狂刷百万反被骂穷逼,我反手送她队友出道(秦薇)
  • 全书浏览老公将我第十个孩子送给情人后,我果断改嫁他绝嗣干爹(苏云遮盛炽)_老公将我第十个孩子送给情人后,我果断改嫁他绝嗣干爹(苏云遮盛炽)全书结局
  • 全文无边怨恨是她活下来的最大动力(江寒静顾榕赫)列表_全文无边怨恨是她活下来的最大动力
  • 全文爸爸死后,消失二十年的妈妈带着儿子回来跟我争家产(顾霆锋顾青卿)列表_全文爸爸死后,消失二十年的妈妈带着儿子回来跟我争家产
  • 霍晚清赵旭然_霍晚清赵旭然
  • 弟弟看的破茧时光沉淀后的深情相拥林悦苏然全书在线
  • 风雨里独自成长全书顾晚妍江知屿在线
  • 爸妈在我房间偷偷安了摄像头(周凝国家不保护废物),爸妈在我房间偷偷安了摄像头
  • 全书浏览雁过雪融向春洲(顾寻煜余芷鸢)_雁过雪融向春洲(顾寻煜余芷鸢)全书结局

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

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