Мерцает, пока макет виден / пропал - PullRequest
0 голосов
/ 02 ноября 2018

Есть ли способ скрыть вид, не мигая его вид сверху?

Я пытаюсь скрыть вид ниже MapView. Как только я установил его видимость на GONE, MapView мерцает. Поскольку мне нужно динамически добавлять больше маркеров, я не смог сохранить MapView и bottomView в FrameLayout, поскольку bottomView будет скрывать эти маркеры на экранах небольшого размера.

Компоновка:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true">


    <com.myapp.widgets.MapPlacePicker
        android:id="@+id/lay_fr_map_inc"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/options_layout" />

    <LinearLayout
        android:id="@+id/options_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:animateLayoutChanges="true"
        android:background="#FFFFFF"
        android:orientation="vertical"
        android:visibility="visible">

        <com.myapp.widgets.FontTextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:padding="10dp"
            android:text="Please select a location!!"
            android:textAppearance="@android:style/TextAppearance.Small" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <com.aigestudio.wheelpicker.WheelPicker
                android:id="@+id/main_option_view"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="0.5"
                app:wheel_atmospheric="true"
                app:wheel_curved="false"
                app:wheel_item_space="15dp"
                app:wheel_item_text_color="#ffafafaf"
                app:wheel_item_text_size="12dp"
                app:wheel_selected_item_text_color="@color/colorPrimary"
                app:wheel_visible_item_count="3" />

        </LinearLayout>
    </LinearLayout>

</RelativeLayout>

Выход:

Flickers

Я также пытался TranslationAnimation, но не повезло. Он показывает больше серого пространства, чем раньше.

        int fromY = (visibility == View.GONE) ? 0 : optionLayout.getHeight();
        int toY = (visibility == View.GONE) ? optionLayout.getHeight() : 0;
        if (visibility == View.VISIBLE) {
            optionLayout.setVisibility(visibility);
        }
        TranslateAnimation animate = new TranslateAnimation(
                0,                 // fromXDelta
                0,                 // toXDelta
                fromY,                 // fromYDelta
                toY); // toYDelta
        animate.setDuration(1000);
        animate.setInterpolator(new AccelerateDecelerateInterpolator());
        //animate.setFillAfter(false);
        animate.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                if (visibility == View.GONE)
                    optionLayout.setVisibility(visibility);
                optionLayout.clearAnimation();
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
        optionLayout.startAnimation(animate);

1 Ответ

0 голосов
/ 03 ноября 2018

Я не вижу мерцания в этой анимации; если вы хотите избежать поведения вертикального изменения размера lay_fr_map_inc, то вы можете просто удалить этот атрибут:

android:layout_above="@+id/options_layout"

... и, возможно, сделать высоту match_parent. Тогда lay_fr_map_inc останется на полную высоту, но нижняя часть будет скрыта options_layout, когда появится (вместо того, чтобы перемещаться вверх).

Не забывайте менять заполнение карты при этом, чтобы не скрывать логотип Google (что является нарушением правил ): setPadding()

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...