3

최근에 Jelly Bean 장치에서 내 응용 프로그램을 테스트하고 내 Actionbar Dodging Code가 더 이상 작동하지 않는다는 사실을 알았습니다.Jelly Bean android.R.id.content가 변경 되었습니까?

OverlayMode가 true 인 투명 작업 표시 줄이 있지만 일부 화면에서 단단한 작업 표시 줄처럼 동작 표시 줄을 실행하려고합니다.

내가 Acionbar 높이를 확인 내가 허니 콤 갤러리 Code

Basicly에서 일부 코드를 차용 한이 작업을하고이 값에 android.R.id.content 버킷의 topMargin을 설정합니다.

public void setupActionbar() { 
    final int sdkVersion = Build.VERSION.SDK_INT; 
    int barHeight = getSupportActionBar().getHeight(); 
     if (sdkVersion < Build.VERSION_CODES.HONEYCOMB) { 
     FrameLayout content = (FrameLayout) findViewById(android.R.id.content); 
     RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) content.getLayoutParams(); 

     if (params.topMargin != barHeight) { 
      params.topMargin = barHeight; 
      content.setLayoutParams(params); 
     } 

     if (!getSupportActionBar().isShowing()) { 
      params.topMargin = 0; 
      content.setLayoutParams(params); 
     } 
     } else { 
     FrameLayout content = (FrameLayout) findViewById(android.R.id.content); 
     LayoutParams params = content.getLayoutParams(); 
     if (params instanceof RelativeLayout.LayoutParams) { 
      android.widget.RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) params; 
      if (lp.topMargin != barHeight) { 
      lp.topMargin = barHeight; 
      content.setLayoutParams(lp); 
      } 

      if (!getActionBar().isShowing()) { 
      lp.topMargin = 0; 
      content.setLayoutParams(lp); 
      } 
     } else if (params instanceof FrameLayout.LayoutParams) { 
      FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params; 
      if (lp.topMargin != barHeight) { 
      lp.topMargin = barHeight; 
      content.setLayoutParams(params); 
      } 

      if (!getActionBar().isShowing()) { 
      lp.topMargin = 0; 
      content.setLayoutParams(params); 
      } 
     } 

     } 

젤리에서는이 전략이 더 이상 작동하지 않습니다. Jelly Bean이 id.content 컨테이너 perhabs를 변경 했습니까?

답변

4

여기에 내 자신의 질문에 답변했습니다. 먼저 난 내 코드에 오타했다 :

content.setLayoutParams(params); should read 
content.setLayoutParams(lp); 

을하지만 진짜 문제는

FrameLayout content = (FrameLayout) findViewById(android.R.id.content); 

상태 표시 포함한 전체 화면의보기를 제공하는 것이 었습니다. 만 안드로이드 4.1 젤리 빈은

View content = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0); 

는 투명 실행 바에서 추진 될 필요가 RootContentView을 제공합니다.

관련 문제