Мне необходимо, чтобы noConnectionView отображался, но никак не мешал нажимать на кнопки…
- User
Мне необходимо, чтобы noConnectionView отображался, но никак не мешал нажимать на кнопки из buttonToggleGroup, как это сделать?
code<FrameLayout android:id="@+id/toolbar_blur_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:foreground="@color/achievements_toolbar_tint" tools:layout_height="?attr/actionBarSize" /> <LinearLayout android:id="@+id/content_container" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:layout_marginTop="?attr/actionBarSize"> <ru.maxi.mobile.uikit.components.toggleGroup.ButtonToggleGroup android:id="@+id/tabs_button_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginHorizontal="@dimen/std_margin" android:layout_marginTop="@dimen/std_margin" android:layout_marginBottom="@dimen/std_half_margin" tools:checkedButton="@id/received_tab"> <Button android:id="@+id/in_progress_tab" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/achievements_in_progress_tab_title" /> <Button android:id="@+id/received_tab" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/achievements_received_tab_title" /> </ru.maxi.mobile.uikit.components.toggleGroup.ButtonToggleGroup> <androidx.viewpager2.widget.ViewPager2 android:id="@+id/tabs_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" /> </LinearLayout> <ru.maxi.mobile.uikit.components.noConnectionView.NoConnectionView android:id="@+id/no_connection_view" android:layout_width="match_parent" android:layout_height="match_parent" android:theme="@style/ThemeOverlay.Achievements.NoConnectionView" android:visibility="visible" /> <ru.maxi.mobile.uikit.components.loaderWithBackground.LoaderWithBackground android:id="@+id/loader_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:theme="@style/ThemeOverlay.Achievements.LoaderWithBackground" /> - Assistant
Для того чтобы
noConnectionViewне мешал нажимать на кнопки изbuttonToggleGroup, нужно сделать его "прозрачным" для нажатий. В Android это достигается с помощью установки атрибутаandroid:clickableвfalseиandroid:focusableвfalse. Это позволит нажатиям проходить сквозьnoConnectionView.Вот как можно изменить XML для
noConnectionView:xml<ru.maxi.mobile.uikit.components.noConnectionView.NoConnectionView android:id="@+id/no_connection_view" android:layout_width="match_parent" android:layout_height="match_parent" android:theme="@style/ThemeOverlay.Achievements.NoConnectionView" android:visibility="visible" android:clickable="false" android:focusable="false" />Теперь
noConnectionViewбудет визуально отображаться, но вам нужно будет убедиться, что он не перехватывает события касания. Если потребуется, можно также сделать его невосприимчивым к другим типам событий, аналогичным образом. - User
Не помогает
- Assistant
Если установка атрибутов
android:clickable="false"иandroid:focusable="false"не помогла, возможно потребуется более сложный подход для того чтобы события касания проходили сквозьnoConnectionView. Ниже приведён альтернативный способ решения этой проблемы.Подход с использованием
ViewGroupи методаdispatchTouchEvent-
Создайте дочерний класс от
NoConnectionView:Если у вас есть доступ к исходному коду приложения, создайте новый класс, который наследуется от . Переопределите метод так, чтобы он не перехватывал события касания:
-