2011-04-19 2 views
0

AdWhirl을 앱에 통합했습니다. AdWhirl 뷰가 내 주요 활동의 레이아웃 하단에 표시되도록 설정했습니다. 내 기본 레이아웃에 몇 EditText 상자가 있고 응용 프로그램이 처음 시작될 때 텍스트 상자를 클릭하면 소프트 키보드가 정상적으로 표시됩니다. 그러나 다른 활동으로 돌아가서 내 주요 활동으로 돌아 가면 EditText를 클릭하면 소프트 키보드가 맨 위의 AdWhirl보기로 표시되고 EditText 상자를 덮습니다. 나는 이것을 며칠 동안 애써왔다. 어떤 도움을 주시면 감사하겠습니다.Adview가 소프트 키보드 상단에 표시

나는 모든 활동에 대해 내 매니페스트에서 android : windowSoftInputMode = "adjustPan"을 정의했습니다. 당신 글고 상자에 onFocusChangeListener 설정

<RelativeLayout android:id="@+id/RelativeLayout01" 
android:layout_width="fill_parent" android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<ImageView android:id="@+id/ImageView02" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:background="@drawable/other_bg_small" android:layout_weight="1"/> 

<ImageView android:id="@+id/ImageView01" 
    android:layout_width="fill_parent" android:layout_height="wrap_content" 
    android:background="@drawable/banner" android:layout_alignParentTop="true" 
    android:paddingBottom="30dip"/> 

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    android:stretchColumns="1" android:gravity="center"  android:id="@+id/table01" 
    android:layout_below="@id/ImageView01" > 

    ... Table stuff 
</TableLayout> 

<LinearLayout android:layout_width="fill_parent" 
    android:id="@+id/ad_layout" android:layout_height="wrap_content" 
    android:gravity="bottom" android:layout_alignParentBottom="true" 
    android:layout_alignBottom="@+id/RelativeLayout01" android:layout_weight="1"> 

    <com.adwhirl.AdWhirlLayout android:id="@+id/adwhirl_layout" 
     android:layout_width="fill_parent" android:layout_height="wrap_content"/> 

</LinearLayout> 

</RelativeLayout> 

답변

2

시도 :

여기 내 main.xml에 레이아웃입니다. 초점이 잡히면 AdWhirl보기 가시성을 View.INVISIBLE로 설정하여 텍스트 상자를 방해하지 않도록하고 포커스가 사라지면 다시 표시되도록 설정하십시오.

final AdWhirl ad = (AdWhirl)findViewById(R.id.adwhirlAd); 
     EditText et = (EditText)findViewById(R.id.editTextBox); 
     et.setOnFocusChangeListener(new OnFocusChangeListener() { 

      @Override 
      public void onFocusChange(View v, boolean hasFocus) { 

       ad.setVisibility(hasFocus ? View.INVISIBLE : View.VISIBLE); 

      } 
     }); 
+0

, 유일한 문제는 내가 2의 EditText 상자를 가지고 있고 각 하나에 솔루션을 구현하는 경우, 광고가 –

+5

프로그래밍 방식으로 설정하십시오 ... 보여주지 않을 것입니다 getWindow()를 사용하여. setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); onCreate에서. – Joe

+0

나는 그것이 효과가 있다고 생각한다! 감사! 왜 매니페스트 특성이 집착하지 않는지 궁금합니다 ... –

0

나는 android : windowSoftInputMode = "adjustPan"설정을 시도했다. AdMob 배너 은 제외하지만도 EdiText입니다. 나는 또한 대답을 시도했지만 edittext는 키보드가 열리지 않고 포커스를 얻을 수 있습니다. 그래서 내가 찾은 해결책은 키보드가 열릴 때 adMob 배너를 숨기는 것입니다. 키보드가 열린 경우 감지하는 방법을 배웠습니다 here. 여기 내 솔루션입니다 :

final View activityRootView = findViewById(R.id.sample_main_layout); 
      activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { 
       @Override 
       public void onGlobalLayout() { 
        int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight(); 
        if (heightDiff > Support.dpToPx(MainActivity.this, 200)) { // if more than 200 dp, it's probably a keyboard... 
         mAdView.setVisibility(View.GONE); 
        } 
        else{ 
         mAdView.setVisibility(View.VISIBLE); 
        } 
       } 
      }); 
도움이 보인다