#StackBounty: #java #android #kotlin #swipe #android-tablayout Even with swiping disabled, tab continues to be changed with touch movem…

Bounty: 50

I am developing an application that uses the tablayout and contains 3 guides. The first is for general user information, the second guide is for additional information and the last guide is for the user to draw on the screen. is a third company that has problems, even with swiping disabled, when making drawing movements, the user ends up returning to the previous tab. So, I would like to know how to disable the movement of the swip on this screen, even with the movement between tabs it is already disabled with the sliding movement, without making it impossible for the drawing to be made.

One thing to note is that when you start drawing from the bottom up or up and down, you can draw without changing as guides, even if you are going somewhere later. However, if you start drawing

One thing I noticed, that when I start to draw from the bottom up or up and down, I can draw without changing the tabs, even if I go anywhere afterwards. However, if I start drawing anywhere, he understands that it is not the drawing but that I want to change tabs. How can I fix this?

class Main2Activity : AppCompatActivity() {

@SuppressLint("ClickableViewAccessibility")
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main2)
    val sectionsPagerAdapter = SectionsPagerAdapter(this, supportFragmentManager)
    val viewPager: ViewPager = findViewById(R.id.viewPager)
    viewPager.adapter = sectionsPagerAdapter
    viewPager.setOnTouchListener { _, _ -> return@setOnTouchListener true }
    val tabs: TabLayout = findViewById(R.id.tabs)
    tabs.setupWithViewPager(viewPager)

   }
}

fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.ufrn.dissertation.activities.Main2Activity">

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:minHeight="?actionBarSize"
        android:padding="@dimen/appbar_padding"
        android:text="@string/app_name"
        android:textAppearance="@style/TextAppearance.Widget.AppCompat.Toolbar.Title" />

    <com.google.android.material.tabs.TabLayout
        android:id="@+id/tabs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary" />
  </com.google.android.material.appbar.AppBarLayout>

<androidx.viewpager.widget.ViewPager
    android:id="@+id/viewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clickable="false"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Image Fragment

class ImagesFragment : Fragment() {
override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    val view = inflater.inflate(R.layout.fragment_imagens, container, false)
 ...CODE DRAWING...

Drawind starting from bottom/up or up/down

Drawind starting from left/right or right/left



Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.