积跬步

Just do IT Now.


  • Home

  • Tags

  • Categories

  • Archives

  • Search

Xml

Posted on 2023-03-30 | In Android代码片段

遍历出xml中的属性

例子1

set.xml

Read more »

UI-图片ImageView、Bitmap、Drawable

Posted on 2023-03-22 | In Android

ImageView:ScaleType属性

ScaleType.FIT_CENTER 默认

该模式是ImageView的默认模式,如果没有设置ScaleType时,将采用这种模式展示图片。在该模式下,图片会被等比缩放到能够填充控件大小,并居中展示:

Read more »

UI-FlexboxLayout

Posted on 2023-03-08 | In Android

流式布局(弹性布局)

添加依赖

1
2
3
dependencies {
implementation 'com.google.android:flexbox:1.0.0'
}
Read more »

UI-折叠布局CollapsingToolbarLayout

Posted on 2023-02-23 | In Android

CollapsingToolbarLayout

简介

  • 一个FrameLayout
  • 用于实现可折叠的标题栏,通常在子布局中放一个Toolbar
  • 必须作为 AppBarLayout 的子类,才能发挥出效果
Read more »

Jetpack Hilt

Posted on 2022-12-27 | In Kotlin扩展

Hilt 的使用

基本使用

用 @Inject 对变量进⾏注解,表示「这个变量要用依赖注入的⽅式来加载」:

Read more »

RecyclerView核心要点

Posted on 2022-12-19 | In Hencoder

RecyclerView核心要点

RecyclerView是什么?

a flexible view for providing
a limited window into
a large data set

Read more »

Java多线程和线程同步

Posted on 2022-12-19 | In Hencoder

Java多线程和线程同步

进程和线程

  • 进程和线程

    • 操作系统中运行多个软件
    • 一个运行中的软件可能包含多个进程
    • 一个运行中的进程可能包含多个线程
  • CPU线程和操作系统线程

    • CPU线程
      • 多核CPU的每个核各自独立运行,因此每个核一个线程
      • “四核八线程”:CPU硬件方在硬件级别对CPU进行了一核多线程的支持(本质上依然是每个核一个线程)
      • 单核CPU也可以运行多线程操作系统
  • 线程是什么:按代码顺序执行下来,执行完毕就结束的一条线

    • UI线程为什么不会结束?

      因为它在初始化完毕后会执行死循环,循环的内容是刷新界面

Read more »

手写热更新

Posted on 2022-11-24 | In 其他IT

手写热更新

热更新 / 热修复

不安装新版本的软件,直接从⽹络下载新功能模块来对软件进⾏局部更新

Read more »

AndroidInterview-Q-A

Posted on 2022-11-01 | In 678

AndroidInterview-Q-A

Java

ClassNotFoundException和NoClassDefFoundError的区别

Read more »

从Retrofit的原理来看HTTP

Posted on 2022-08-31 | In Android

Retrofit使用方法简介

  1. 创建一个interface作为Web Service的请求集合,在里面用注解(Annotation)写入需要配置的请求方法

    1
    2
    3
    4
    public interface GitHubService{
    @GET("users/{user}/repos")
    Call<List<Repo>> listRepos(@Path("user") String user);
    }
  2. 在正式代码里用Retrofit创建出interface的实例

    1
    2
    3
    4
    Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("https://api.github.com/")
    .build();
    GitHubService service = retrofit.create(GitHubService.class);
  3. 调用创建出的Service实例的对应方法,创建出相应的可以用来发起网络请求的Call对象

    1
    Call<List<Repo>> repos = service.listRepos("octocat");
  4. 使用Call.execute()或者Call.enqueue()来发起请求

    1
    repos.enqueue(callback);

Retrofit源码结构总结

Read more »

源码-ComponentActivity的LifecycleOwner

Posted on 2022-08-25 | In Android

原文:https://weread.qq.com/web/reader/d82322e0813ab6e2eg015684

起因:使用Dialog未dismiss时Activity关闭了,导致内存泄露
解决:给Dialog添加生命周期监听

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class TipDialog(context: Context) : Dialog(context), LifecycleObserver {
init {
if (context is ComponentActivity) {
(context as ComponentActivity).lifecycle.addObserver(this)
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.item_tip_dialog)
}
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
private fun onDestroy() {
if (isShowing) {
dismiss()
}
}
}
Read more »

Gradle配置文件拆解

Posted on 2022-08-15 | In Gradle

Gradle配置文件拆解

gradle配置文件里的内容其实“方法调用”,长得类似与json,其实是groovy中的“闭包”(Closure)知识:把方法当作形参传递进去

java中无法把方法当形参传递,有类似的监听(把方法放进一个类中,用匿名内部类的形式把类的对象传进去)(里面的回调就是延后执行的)【=>闭包内容不一定马上执行】

Read more »
<1…456…23>

265 posts
23 categories
47 tags
E-Mail CSDN
0%
© 2018 — 2025 阿炳
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4