Отображение рекламы сверху на мягкой клавиатуре - PullRequest
0 голосов
/ 19 апреля 2011

Я только что интегрировал AdWhirl в свое приложение. У меня настроен вид AdWhirl, чтобы он отображался в нижней части макета моей основной деятельности. У меня есть несколько полей EditText на моем основном макете, и когда приложение запускается впервые, щелкнув текстовые поля, отображается программная клавиатура в обычном режиме. Однако, когда я перехожу к другому занятию и возвращаюсь к своему основному занятию, затем нажимаю EditText, выскакивает программная клавиатура с видом AdWhirl сверху, закрывая мое поле EditText. Я боролся с этим в течение нескольких дней. Любая помощь будет оценена.

У меня есть android: windowSoftInputMode = "AdjustPan", определенный в моем манифесте для всех действий.

Вот мой макет main.xml:

<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 ]

2 голосов
/ 19 апреля 2011

Попробуйте установить onFocusChangeListener для ваших полей EditText.Когда они получат фокус, установите видимость представления 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 голосов
/ 06 ноября 2016

Я попытался установить Android: windowSoftInputMode = "AdjustPan".он скрывает баннер adMob , но и EdiText.Я также попробовал принятый ответ, но текст редактирования может получить фокус без открытия клавиатуры.Поэтому решение, которое я нашел, - это скрыть баннер adMob при открытии клавиатуры.Я узнал, как определить, открывается ли клавиатура здесь .и вот мое решение:

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);
                    }
                 }
            });
...