Android小Tip

1,动态改变textView的颜色

String s = "这是" + "" + "变色的" + "" + "字";
textView.setText(Html.fromHtml(s));

2,全屏并设置透明栏

/**
 * 设置透明状态栏,需要写在设置布局前,最好是在BaseActivity中写
 */
private void setStatusBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isStatusBarWhite()) {
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        } else {
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(0);
    }
}
protected boolean isStatusBarWhite() {
    return false;
}

3,进入界面不弹出输入框

在EditText外围布局加上:

android:focusable="true"
android:focusableInTouchMode="true"

 

你可能感兴趣的:(Android小技巧)