Andorid复习

embedded/2024/10/19 3:33:29/

组件

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/embedded/28124.html

相关文章

“Postman 中文版使用教程:如何切换到中文界面?”

Postman 的很好用的接口测试软件。但是&#xff0c;Postman 默认是英文版的&#xff0c;也不支持在软件内切换为中文版。很多同学的英语并不是很好&#xff0c;看到一堆的英文很是头痛。 今天我们来介绍下&#xff1a;切换到 Postman 中文版的方法。想要学习更多的关于 Postma…

使用Python爬虫会遇到的问题和解决方法(包含案例)

一、HTTP错误&#xff08;如403 Forbidden&#xff09; 问题描述&#xff1a; 当使用requests库发起请求时&#xff0c;可能会遇到HTTP 403 Forbidden错误&#xff0c;这通常意味着服务器理解了请求&#xff0c;但是拒绝执行它。 解决方法&#xff1a; 1.设置headers&#xf…

如何基于Zookeeper实现注册中心模型?

在分布式系统中&#xff0c;通常会存在几十个甚至上百个服务&#xff0c;开发人员可能甚至都无法明确系统中到底有哪些服务正在运行。另一方面&#xff0c;我们很难同时确保所有服务都不出现问题&#xff0c;也很难保证当前的服务部署方式不做调整和优化。由于自动扩容、服务重…

每日一题(力扣198):打家劫舍--dp

考虑到达第n家房屋时&#xff0c;偷偷这家的钱 &#xff1a;1 如果不偷&#xff0c;那么当前最大值是前n-1家房屋中可以偷的最多的钱 2 如果偷 &#xff0c;那就是这家的钱 &#xff0b;前n-2家房屋可以偷的最多的钱。&#xff08;从数组的结果值考虑&#xff0c;不然容易绕进去…

算法二:DOM - 将DOM节点元素转换成JSON字符串

题目&#xff1a; 将DOM节点元素转换成JSON的格式 例如 <div class"root"><div class"child1"><p></p></div><span></span><div><div><p></p></div></div><p></…

centos学习- ps命令详解-进程监控的利器

ps命令详解&#xff1a;Linux进程监控的利器 在Linux系统管理中&#xff0c;进程监控是一个至关重要的环节。ps命令是Linux系统中一个功能强大的进程查看工具&#xff0c;通过它可以获取当前系统中所有进程的快照信息&#xff0c;并深入了解各个进程的详细信息。结合其各种选项…

蓝桥杯如何准备国赛?

目录 一、赛前准备 1、如何刷题&#xff0c;刷哪些题&#xff1f; 2、记录&#xff08;主要看个人习惯&#xff09; CSDN博客 写注释 3、暴力骗分 4、从出题人的角度出发&#xff0c;应该如何骗分 二、赛中注意事项 一、赛前准备 1、如何刷题&#xff0c;刷哪些题&…

Java 使用 Maven 编译时插件提示 拷贝错误

提示的具体信息为&#xff1a; [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.3.1:resources (default-resources) on project core-java-8: filtering C:\WorkDir\Repository\iSharkfly-Docs\java-tutorials\core-java-modules\core-jav…