키보드 on/off 를 감지해서 키보드가 on 됐을때 애드몹광고를 지우고, off 됐을때 애드몹 광고를 다시 보여주는 코드임
final View activityRootView = findViewById(R.id.roo_layout);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Rect r = new Rect();
activityRootView.getWindowVisibleDisplayFrame(r);
int heightDiff = activityRootView.getRootView().getHeight() - (r.bottom - r.top);
if (heightDiff > 100) {
Log.d("kth", "activityRootView on");
adView.setVisibility(View.GONE);
} else {
Log.d("kth", "activityRootView off");
adView.setVisibility(View.VISIBLE);
}
}
});
'Android > 개발팁' 카테고리의 다른 글
| Thread Hanlder 간단하게 쓰기 (0) | 2013.07.24 |
|---|---|
| ★ setBackground vs setBackgroundDrawable / AlertDialog (0) | 2013.07.12 |
| How to replace R.drawable.“someString” (0) | 2013.06.25 |
| What adapter shall I use to use HashMap in a ListView (0) | 2013.06.25 |
| Intent 로 gallery 의 특정 폴더 띄우기. (1) | 2013.05.31 |