0

I am trying to allow the user to put a ring on the circle on the screen and then press the larger button so that the circle goes to the next ring size.

Everything work fines when no ring is on the screen.

However when a ring it on the screen no other touches are called and the buttons and the seekbar does not work.

I'm new in android and i haven't came across this requirement before. Is there a way I can allow multi-touch gestures on the activity or a way to ignore touches on that specific layout?

enter image description here

XML File

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/White" 
    android:splitMotionEvents="false"
    >

<TextView
    android:id="@+id/us"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/uslbl"
    android:padding="@dimen/standard_margin"
    android:text="size"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/pressed_gemporia" />

<TextView
    android:id="@+id/uklbl"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/uslbl"
    android:padding="@dimen/standard_margin"
    android:text="UK Size:"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/Black" />

<TextView
    android:id="@+id/uk"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/uklbl"
    android:layout_alignBottom="@+id/uklbl"
    android:layout_toRightOf="@+id/uklbl"
    android:padding="@dimen/standard_margin"
    android:text="size"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/pressed_gemporia" />

<ImageView
    android:id="@+id/ci"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />

<TextView
    android:id="@+id/uslbl"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentStart="true"
    android:layout_alignParentTop="true"
    android:layout_toLeftOf="@+id/uk"
    android:gravity="left"
    android:padding="@dimen/standard_margin"
    android:text="US Size:"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:textColor="@color/Black" />

<SeekBar
    android:id="@+id/seekbar"
   android:progressDrawable="@drawable/red_scrubber_progress"
android:thumb="@drawable/red_scrubber_control"

     android:max="8"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/divider" />

<View
    android:id="@+id/divider"
    android:layout_width="fill_parent"
    android:layout_height="1dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/uklbl"
    android:layout_marginTop="18dp"
    android:background="@color/pressed_gemporia" />




<TextView
    android:id="@+id/sizes"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
      android:padding="@dimen/standard_margin"
    android:layout_below="@+id/seekbar"
    android:text="TextView"    android:textColor="@color/pressed_gemporia"  />

<Button
    android:id="@+id/right"
    android:layout_width="100dp"
    android:textColor="@color/pressed_gemporia" 
    android:layout_height="wrap_content"
           android:background="@color/White" 
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/left"
    android:text="Larger" />

<Button
    android:id="@+id/left"
    android:layout_width="100dp"
                   android:background="@color/White" 
    android:textColor="@color/pressed_gemporia" 
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:text="Smaller" />

<ImageView
    android:id="@+id/ring"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/ci"
    android:layout_centerHorizontal="true"
    android:src="@drawable/j" />

Java Code

  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         setContentView(R.layout.ring_sizes);

         left = (Button)findViewById(R.id.left);
         right = (Button)findViewById(R.id.right);
         us = (TextView)  findViewById(R.id.us);
         uk = (TextView)  findViewById(R.id.uk);
         ci = (ImageView)findViewById(R.id.ci);
         ring = (ImageView)findViewById(R.id.ring);
         sizes.add(R.drawable.j);
         sizes.add(R.drawable.l);
         sizes.add(R.drawable.n);
         sizes.add(R.drawable.p);
         sizes.add(R.drawable.r);
         sizes.add(R.drawable.t);
         sizes.add(R.drawable.v);
         sizes.add(R.drawable.x);
         sizes.add(R.drawable.z);

         USsizes.add("5");
         USsizes.add("6");      
         USsizes.add("7");       
         USsizes.add("8");       
         USsizes.add("9");      
         USsizes.add("10");      
         USsizes.add("11");      
         USsizes.add("12");      
         USsizes.add("13");      

         UKsizes.add("J-K");
         UKsizes.add("L-M");        
         UKsizes.add("N-O");         
         UKsizes.add("P-Q");         
         UKsizes.add("R-S");        
         UKsizes.add("T-U");         
         UKsizes.add("V-W");         
         UKsizes.add("X-Y");         
         UKsizes.add("Z+"); 

         color = (getBaseContext().getResources().getColor(R.color.pressed_gemporia));
         value = (TextView) findViewById(R.id.sizes);
         seekbar = (SeekBar) findViewById(R.id.seekbar);


         seekbar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));

          value.setText("UK Size : "+UKsizes.get(0) + " - US Size: " + USsizes.get(0));
             setUpViews();
                                        seekbar.setOnSeekBarChangeListener( new OnSeekBarChangeListener()
        {
        public void onProgressChanged(SeekBar seekBar, int progress,
                                                                        boolean fromUser)
        {

            ring.setImageResource(sizes.get(progress));

                us.setText(USsizes.get(progress));
                uk.setText(UKsizes.get(progress));
                counter=progress;


value.setText("UK Size : "+UKsizes.get(progress) + " - US Size: " + USsizes.get(progress));

                                                        }

         public void onStartTrackingTouch(SeekBar seekBar)
        {
                   // TODO Auto-generated method stub
                                                        }

     public void onStopTrackingTouch(SeekBar seekBar)
        {
         // TODO Auto-generated method stub
                                                        }
        });


    }


    public void setUpViews(){


        ring.setImageResource(sizes.get(counter));

            us.setText(USsizes.get(counter));
            uk.setText(UKsizes.get(counter));


             right.setOnClickListener(new View.OnClickListener()
             {
                 @Override
                 public void onClick(View view)
                 {
                     if(UKsizes.size()>counter+1){

                            ring.setImageResource(sizes.get(counter+1));


                 seekbar.setProgress(counter+1);


                     }

                 }
             });


             left.setOnClickListener(new View.OnClickListener()
             {
                 @Override
                 public void onClick(View view)
                 {
                     if(counter!=0){

                            ring.setImageResource(sizes.get(counter));

                 seekbar.setProgress(counter-1);




                     } }
             });





    }

}
user3328051
  • 57
  • 10
  • just remember that not all devices support multi-touch, so when you solve this problem, still give another way for the user to work with the rings. – Richard Le Mesurier Jun 03 '14 at 08:37
  • is there a way to completely ignore or disable touch events on th circle image? – user3328051 Jun 03 '14 at 09:36
  • Please rename your views to make your code easier to read, recompile and rerun your app to make sure it still works as before, repost your xml with the new names, and post your java code as well. The symptom you're describing shouldn't be happening even without multi-touch, so I doubt that adding multi-touch will change anything (except making the code unnecessarily more complex). That's why we need to see your java code. – Stephan Branczyk Jun 03 '14 at 10:09
  • @StephanBranczyk I have added what you requested. Thanks – user3328051 Jun 03 '14 at 10:20

1 Answers1

0

There is a way to ignore touches in particular layout,for that you should add

 android:splitMotionEvents="false"

in your layout . You can refer answers from thie following link https://stackoverflow.com/questions/12777435/disable-multi-finger-touch-in-my-app

Community
  • 1
  • 1
Anu
  • 1,303
  • 3
  • 23
  • 38
  • Hi I have tried what you said and i also read the other question but it doesn't seem to work. I have updated my question with my xml file. Could you check it out and advice me where to put that line of code. I have also tried to add different relative layouts for each section and adding the android:splitMotionEvents="false" but it still doesn't work. Thanks! – user3328051 Jun 03 '14 at 09:25
  • please put that line in yout outer relative layout – Anu Jun 03 '14 at 10:08