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?
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);
} }
});
}
}