Android开发中容易遗忘的小知识

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/f552126367/article/details/85341230

1、给页面添加背景 

 WindowManager.LayoutParams lp = getWindow().getAttributes();
        /**
         * 此处设置亮度值。dimAmount代表黑暗数量,也就是昏暗的多少,设置为0则代表完全明亮。 范围是0.0到1.0
         */
        lp.dimAmount = (float) 0.3;

2、国内镜像地址

jcenter(){ url 'http://jcenter.bintray.com/'}

3、Android原生Js之间交互。以及它们之间通信桥梁JsBridge

4、超快的Android数据库存储ObjectBox

5、延迟更新界面,判断当为UI线程时执行方法。

public final void runOnUiThread(Runnable action) {
    if (Thread.currentThread() != mUiThread) {
        mHandler.post(action);
    } else {
        action.run();
    }
}

6、AndroidMainfest.xml报错Permission is only granted to systems apps修改方法
File--setting--Editor--Inspections--Android--lint--correctness--using system app permissing将error修改为warning

7、AutoCompleteTextView:是EditText的直接子类,与普通EditText的最大不同就是。在用户输入的过程中,能够列出可供选择的输入项。方便使用者,需要编写adapter来显示下拉内容。

8、EventBus:可以通过eventbus来进行消息的传递。

9、super.方法:表示调用父类中和和该方法同名的所有内容,如果不写super则是完全重写该方法。

10、textview和edittext超过设置的行数显示...的方法:

android:ellipsize = "end"    省略号在结尾
android:ellipsize = "start"   省略号在开头
android:ellipsize = "middle"     省略号在中间
android:ellipsize = "marquee"  跑马灯
android:singleline = "true"

11、this.getSharedPreferences("SP", MODE_PRIVATE);表示写入的文件是私有的,只能被应用本身访问。

扫描二维码关注公众号,回复: 5325842 查看本文章

12、Android开发中经常会在setContentView(R.layout.XXX); 前设置requestWindowFeature(Window.FEATURE_NO_TITLE)。

他的意思是需要软件全屏显示、自定义标题(使用按钮等控件)和其他的需求

13、setWebChromeClient:是html5中在影响【View】的事件到来时,会通过WebViewClient中的方法回调通知用户

14、studio如何下载aar包:坑爹的包下载,需要在包后加入@aar,如下,不然在自己的私服nexus无法下载。

compile 'me.iwf.photopicker:PhotoPicker:0.9.5@aar'

15、apt的使用:

apt是一个注解工具,它对源代码文件进行检测找出其中的Annotation,使用Annotation进行额外的处理,但是2.2版本以后,Android Gradle 插件提供了名为 annotationProcessor  的功能来完全代替  android-apt,项目中如下全部去掉,apt引用改为annotationProcessor引用。

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

16、引用assets下的文件的地址:

"file:///android_asset/jsWeb/view/echarts_small.min.js"

17、merge标签

可以理解为是为了优化层级的标签,当子视图的布局不依赖与父视图时,则可以使用merge减少层级。

18、在代码中设置color等属性的SDK》23的方法:

ContextCompat.getColor(context,R.color.white)

猜你喜欢

转载自blog.csdn.net/f552126367/article/details/85341230
今日推荐