編輯:關於Android編程
activity中OnAttachedWindow生命周期在OnResume之後,所以對長寬獲取在推薦在OnAttachedWindow中進行。onDetachedWindow是在OnDestroy之後調用的,按返回鍵會執行,但是按home鍵不會執行。對於xml中的fragment標簽只能是android.support.v4包裡面的fragment及繼承自該類的子類,否則會報 "binary XML file line #6: Error inflating class fragment"錯誤,如果要使用3.0以上版本的fragment 建議是在xml裡面定義一個容器,然後用FragmentTransaction操作容器,添加fragment。TextView的singeLine會使自定義背景的顏色失效。對於EditText控制可編輯性最好的解決辦法就是設置enable的值來控制,比通過代碼調整或者替換控件的方法要好的多。監聽鍵盤的彈起和隱藏事件,推薦是在AndroidManifest.xml對activity的WindowSoftInputMode中設置adjustPan或者adjustResize,具體看哪種適合你的使用環境,然後注冊監聽ViewTreeObserver.OnGlobalLayoutListener,在重載方法onGlobalLayout中判斷彈起還是隱藏。示例代碼如下:
private class MyStateListener implements ViewTreeObserver.OnGlobalLayoutListener {
private final View mDecorView;
private final CameraFragment mFragment;
private int mFrameHeight = 0;
private boolean mKeyboardShow;
private final Rect mVisibleDisplayFrame;
IMEStateListener(CameraFragment paramView, View view) {
this.mFragment = paramView;
this.mDecorView = view;
this.mVisibleDisplayFrame = new Rect();
}
@Override
public void onGlobalLayout() {
this.mDecorView.getWindowVisibleDisplayFrame(mVisibleDisplayFrame);
int i = this.mVisibleDisplayFrame.height();
if (this.mFrameHeight == 0) {
this.mFrameHeight = i;
}
if (i < this.mFrameHeight) {
this.mKeyboardShow = true;
} else if (this.mKeyboardShow) {
this.mKeyboardShow = false;
mHandler.sendEmptyMessage(KEYBOARD_HIDE);
}
}
}
微信怎麼分享音樂 微信朋友圈怎麼分享音樂
在朋友圈,總能看到好友分享的音樂,自己也想來試試,微信怎麼分享音樂?小編將給大家介紹一下微信朋友圈的音樂是怎麼分享的,不懂的朋友可以了解下這裡我們以蘋果iP
Android應用程序的啟動流程
Android系統中一個應用程序的主題是由ActivityThread構成的。不過涉及到很多細節如ActivityThread是由誰來創建的 又是在什麼時間創建?它和系統
android L Palette 實現原理
有時候,看到一些界面上的色彩,心情可能會很舒暢,有時候,看到一些其他色彩,就覺得很討厭,不爽,看到android L Palette 從圖片中提取篩選出來的顏色,覺得都挺
android從init到開機動畫啟動關閉流程一簡易圖(surfaceflinger啟動的位置)
學習下,記錄下,分享下 init主進程啟動,解析init.rc後依次exec fork啟動相關的進程,其中以class main和core為首的service將會率