Можно ли отключить swipe во фрагментах?

Здравствуйте.

Можно ли отключить swipe во фрагментах?

Спасибо.
  • Вопрос задан
  • 563 просмотра
Решения вопроса 1
@Hutaab Автор вопроса
Пишем свой ViewPager:
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class NoSwipeViewPager extends ViewPager{
    private boolean swipeable;

    public NoSwipeViewPager(Context context) {
        super(context);
    }

    public NoSwipeViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.swipeable = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (this.swipeable) {
            return super.onTouchEvent(event);
        }

        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent event) {
        if (this.swipeable) {
            return super.onInterceptTouchEvent(event);
        }

        return false;
    }

    public void setSwipeable(boolean swipeable) {
        this.swipeable = swipeable;
    }
}


Добавляем в разметку:
<com.example......NoSwipeViewPager
                android:id="@+id/container"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"  />

Отключаем Swipe в активити:
private NoSwipeViewPager mViewPager;
        ..............
        mViewPager = (NoSwipeViewPager) findViewById(R.id.container);
        mViewPager.setSwipeable(false);
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
@semenir986
по-моему можно, нужно в настройках поискать
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы