SignaturePad in TabLayout - Strange behaviour when using a stylus

Hi,

i'm using the newest version of Signature-Pad (2.0.0.0) from the Component-Store and Xamarin.Android 7.3, testing with a Samsung Galaxy Note 2 Device.

When using the Signature-Pad in a single Activity everthing is working fine - but in a Tabbed Layout with a ViewPager something strange happens.
Signing with my fingertip is working fine, but with the stylus the lines are only appearing when releasing it from the touchscreen. So signing is very difficult because you cannot see your line.

I've also tried a custom ViewPager with overriding the OnTouchEvent and OnInterceptTouchEvent methods to 'unbind' the Events - i thought maybe because i can slide the tabs is the cause - with no luck.

Code Examples (only snippets)

Main Activity

public class AcceptContainerActivity : Android.Support.V7.App.AppCompatActivity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_acceptcontainer);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.Title = "Accept Container";
            SupportActionBar.SetDisplayShowTitleEnabled(true);

            var fragments = new Fragment[]
            {
                new AcceptContainerOverviewFragment(), //mostly empty
                new AcceptContainerAcceptanceFragment() //here the Signature Pad is implemented
            };

            var titles = CharSequence.ArrayFromStringArray(new[]
                {
                    "Overview",
                    "Acceptance"
                });
            var viewPager = FindViewById<Android.Support.V4.View.ViewPager>(Resource.Id.viewpager);
            viewPager.Adapter = new TabsFragmentPagerAdapter(FragmentManager, fragments, titles);

            // Give the TabLayout the ViewPager
            var tabLayout = FindViewById<Android.Support.Design.Widget.TabLayout>(Resource.Id.sliding_tabs);
            //tabLayout.RequestDisallowInterceptTouchEvent(true);
            tabLayout.SetupWithViewPager(viewPager);
        }
   }

AcceptContainerAcceptanceFragment

public class AcceptContainerAcceptanceFragment : Fragment
{
    public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
    }
    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            var rootView = inflater.Inflate(Resource.Layout.fragment_acceptcontainer_acceptance, container, false);
        signature = rootView.FindViewById<SignaturePadView>(Resource.Id.signatureView);
            signature.StrokeWidth = 2f;
            return rootView;
    }
}

activity_acceptcontainer.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
      <android.support.design.widget.TabLayout
          android:id="@+id/sliding_tabs"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          app:tabMode="fixed" />
      <android.support.v4.view.ViewPager
          android:id="@+id/viewpager"
          android:layout_width="match_parent"
          android:layout_height="0px"
          android:layout_weight="1" />
</LinearLayout>

fragment_acceptcontainer_acceptance.xml (With signature Pad)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
<!--
    Some Controls (EditText) here
-->

     <xamarin.controls.SignaturePadView
          android:id="@+id/signatureView"
          android:layout_width="match_parent"
          android:layout_height="150dp"
           android:background="@color/white"
           />
</LinearLayout>

Thanks for help! If you need more code please let me know it.

Answers

  • DeeponeDeepone Member

    Any news on this ?
    I have the exact same error.

  • ShaunBauerShaunBauer USMember ✭✭
    edited April 2018

    I have the same issue on a Samsung Galaxy Tab A. Using a simple example by @HoussemDellai , I can replicate the stylus bug on version 2.3.

    Downgrading to 2.0 makes the simple example work with a stylus (thanks to simonfanz on Github . However, add the sample into a TabbedLayout and the swipe tab change action overwrites the stroke so all horizontal input changes tab.

    Edit: A workaround is to disable the tab swipe action. Add the below code into the code behind:

    this.On<Xamarin.Forms.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(false);

    Note that I am using SingaturePad.Forms but I figure there is some similarities (apart from the error)

  • pablog1994pablog1994 Member

    I have a problem.
    In the Resource.Id.ViewPager code when I write the "viewpager" nothing appears to me. For what is this?
    Can somebody help me?

  • ShaunBauerShaunBauer USMember ✭✭

    This is fixed in 3.0 (for me anyways)

Sign In or Register to comment.