TextView的高級玩法:CompoundDrawable,shadow,Typeface自定義字體,Shader,HTML渲染(支持自定義tag)、Span(SpannableString:字符級別、段落級別、對其),自定義Span(立式分?jǐn)?shù)、彩虹效果、彩虹動(dòng)效、可點(diǎn)擊URL、Emoji...),用xml定義drawable動(dòng)畫
http://wiki.jikexueyuan.com/project/notes/images/AdvancedTextView.png" alt="AdvancedTextView.png" />
startLockTask();android.intent.action.BOOT_COMPLETED,隨系統(tǒng)啟動(dòng)APP;android.intent.category.HOME、android.intent.category.LAUNCHER、android.intent.category.DEFAULT;@Override
public void onAttachedToWindow() {
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
}@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if(!hasFocus) {
Intent closeDialog =
new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
sendBroadcast(closeDialog);
}
} 例子
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<View
android:id="@+id/first"
android:background="@color/sa_green_dark"
app:layout_heightPercent="50%"
app:layout_marginLeftPercent="25%"
app:layout_marginTopPercent="25%"
app:layout_widthPercent="50%" />
<View
android:layout_width="0dp"
android:layout_height="32dp"
android:layout_alignLeft="@id/first"
android:layout_alignStart="@id/first"
android:layout_alignRight="@id/first"
android:layout_alignEnd="@id/first"
android:layout_below="@id/first"
android:layout_marginTop="8dp"
android:background="@color/light_grey" />
</android.support.percent.PercentRelativeLayout>
http://wiki.jikexueyuan.com/project/notes/images/PercentRelativeLayout.png" alt="PercentRelativeLayout.png" />
protected void attachLayoutAnimationParameters(View child, ViewGroup.LayoutParams params, int index, int count)方法,控制layout動(dòng)畫的播放ACTION_SEND分享文件,并使用了file://形式的Uri,那么接收APP將需要READ_EXTERNAL_STORAGE權(quán)限,否則將會(huì)崩潰;而如果使用content://形式Uri,接收APP將不需要權(quán)限;所以應(yīng)該使用后者形式;packageManager.queryIntentActivities(intent, MATCH_DEFAULT_ONLY);將至多返回一個(gè)結(jié)果;MATCH_ALL這個(gè)flag起作用的前提是尚無通過驗(yàn)證的APP,否則也只會(huì)有一個(gè)結(jié)果;詳見;android:windowSoftInputMode="adjustResize"后,activity內(nèi)的“可折疊”ViewGroup,例如ScrollView會(huì)在鍵盤彈起時(shí)減小其高度,然而如果在activit的theme中設(shè)置android:windowFullscreen="true"或者android:fitsSystemWindows="false",那么adjustResize都將不起作用。Theme.NoDisplay,并且沒有立即finish,那APP將會(huì)ANR,詳見ACTION_PROCESS_TEXT的intent,會(huì)在用戶選擇文本時(shí),提供為其服務(wù)的機(jī)會(huì)<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove"/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE" tools:node="remove"/>defaultConfig {
resConfigs "en", "de", "fr", "it"
resConfigs "nodpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
}sourceSets讓單元測試和集成測試共享代碼,受此啟發(fā),可以更加高度定制化代碼路徑。詳見gradle配置測試顯示log
android {
...
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
outputs.upToDateWhen { false }
showStandardStreams = true
}
}
}
minSdkVersion 21可以加快開發(fā)時(shí)的打包速度通過Intent調(diào)起其他應(yīng)用時(shí),需要先檢查是否有應(yīng)用可以響應(yīng)此Intent:
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(sendIntent);
}
inflater.inflate,第二個(gè)參數(shù)不要傳遞null,第三個(gè)參數(shù)在Fragment::onCreateView和recycler view holder的onCreateViewHolder時(shí),都必須傳false;