Andorid复习

ops/2025/3/26 0:58:18/

组件

TextView

阴影

 android:shadowColor="@color/red" 阴影颜色android:shadowRadius="3.0" 阴影模糊度(大小)android:shadowDx="10.0" 横向偏移android:shadowDy="10.0" 

跑马灯

这里用自定义控件

public class MyTextView extends TextView {public MyTextView(Context context) {super(context);}public MyTextView(Context context, @Nullable AttributeSet attrs) {super(context, attrs);}public MyTextView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);}@Overridepublic boolean isFocused() {return true;//获取聚焦}
}
 <com.example.derry.MyTextViewandroid:id="@+id/tv_one"android:text="@string/tv_one"android:textColor="@color/black"android:layout_width="match_parent"android:textStyle="italic"android:textSize="30sp"android:gravity="center"android:layout_height="200dp"android:shadowColor="@color/red"android:shadowRadius="3.0"android:shadowDx="10.0"android:shadowDy="10.0"下面是跑马灯android:singleLine="true" //一条线显示不自动换行android:ellipsize="marquee" //android:marqueeRepeatLimit="marquee_forever" //循环次数android:focusable="true" //聚焦必写android:focusableInTouchMode="true"  //聚焦必写/>

Button

stabteListDrawable

设置button背景颜色时要改
<resources xmlns:tools="http://schemas.android.com/tools"><!-- Base application theme. -->改下面这行<style name="Base.Theme.Derry" parent="Theme.MaterialComponents.DayNight.Bridge"><!-- Customize your light theme here. --><!-- <item name="colorPrimary">@color/my_light_primary</item> --></style><style name="Theme.Derry" parent="Base.Theme.Derry" />
</resources>
条件选择器
按钮点击变换背景

在drawable中添加button规则

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!--    按下为--><item android:drawable="@drawable/baseline_2k_plus_24" android:state_pressed="true"/>
<!--    不按为  默认为--><item android:drawable="@drawable/ic_android_black_24dp"/>
</selector>

其中@drawable/为导入的xml图片 导入方式为

为页面的button绑定点击规则

  <Buttonandroid:text="我是按钮"android:background="@drawable/btn_select" //规则android:textColor="@color/white"android:layout_width="200dp"android:layout_height="100dp"/>
点击变换背景色

EditText

 配合button点击获取信息

text设置的是全局 Button btn = findViewById(R.id.btn_get);text = findViewById(R.id.text);btn.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String te = text.getText().toString();Log.e("leo", "onClick:输入的内容是 "+te);}});

imageView

    <ImageViewandroid:src="@drawable/ceshi"android:maxWidth="200dp"android:maxHeight="200dp"android:adjustViewBounds="true"android:layout_width="wrap_content"android:layout_height="wrap_content"/>

ProgressBar

点击不显示

  public void leoClick(View view) {if (pb.getVisibility()==View.GONE)//不显示则显示pb.setVisibility(View.VISIBLE);//则显示elsepb.setVisibility(View.GONE);///则隐藏}

 点击进度条加长

 public void load(View view) {int progress = load.getProgress();progress+=10;load.setProgress(progress);}

Notification消息通知

 当android版本大于13时需要在这加上这句

<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

 AlertDiaLog

    <Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:onClick="gaoClick"android:text="显示对话框"/>

  自定义布局

PopupWindow

 


http://www.ppmy.cn/ops/22707.html

相关文章

基于CANoe从零创建以太网诊断工程(2)—— TCP/IP Stack 配置的三种选项

&#x1f345; 我是蚂蚁小兵&#xff0c;专注于车载诊断领域&#xff0c;尤其擅长于对CANoe工具的使用&#x1f345; 寻找组织 &#xff0c;答疑解惑&#xff0c;摸鱼聊天&#xff0c;博客源码&#xff0c;点击加入&#x1f449;【相亲相爱一家人】&#x1f345; 玩转CANoe&…

【论文阅读】ESRT-Transformer for Single Image Super-Resolution

ESRT-Transformer for Single Image Super-Resolution 论文地址摘要1. 引言2.相关工作2.1 基于 CNN 的 SISR 模型2.2 Vision Transformer Transformer 3. Efficient Super-Resolution Transformer3.1. Lightweight CNN Backbone (LCB)3.2. High-frequency Filtering Module (HF…

常用图像加密技术-流密码异或加密

异或加密是最常用的一种加密方式&#xff0c;广泛的适用于图像处理领域。这种加密方式依据加密密钥生成伪随机序列与图像的像素值进行异或操作&#xff0c;使得原像素值发生变化&#xff0c;进而使得图像内容发生变化&#xff0c;达到保护图像内容的目的。 该加密方法是以图像…

PhaGCN2:病毒聚类

https://github.com/KennthShang/PhaGCN2.0 安装 mamba create -n phagcn2 python3.9 numpy pytorch networkx2.5 pandas mcl14.137 diamond0.9.14 biopython1.78 scipy1.5.2 conda activate phagcn2 git clone https://github.com/KennthShang/PhaGCN2.0cd database tar -zx…

浏览器的本地存储---localstorage

web存储对象 Web 存储对象 localStorage 和 sessionStorage 允许我们在浏览器上保存键/值对。 这两个对象保存再本地&#xff08;客户端&#xff09;&#xff0c;允许保存至少 5MB 的数据&#xff08;或更多&#xff09;&#xff0c;这些数据不会因为页面刷新而销毁&#xff0…

QT5之lambda

使用lambda需要 配置c11 所以在点.pro文件里面配置添加如下 CONFIG c11 使用到qDebug 打印包含头文件 #include<QDebug> lambda 表达式使用 代替槽如下 #include "mainwidget.h" #include<QPushButton> #include<QDebug> mainWidget::mainWid…

大厂常见算法50题-替换空格

专栏持续更新50道算法题&#xff0c;都是大厂高频算法题&#xff0c;建议关注, 一起巧‘背’算法! 文章目录 题目解法一 String类replace方法解法二 遍历替换总结 题目 解法一 String类replace方法 String类自带的replace&#xff0c;方法传入两个char类型的参数&#xff0c;分…

20240428如何利用IDM下载磁链视频

缘起&#xff1a; https://weibo.com/tv/show/1034:4864336909500449 中国获奖独立纪录片《阿辉》揭秘红灯区“教父”的生存法则 5,751次观看 1年前 发布于 陕西 身为里中横 67.7万粉丝 互联网科技博主 微博原创视频博主 头条文章作者 https://weibo.com/tv/show/1034:4864…