一个圆形区域,圆的1/4处即上下左右各有一个按钮(即圆的1/4图片),
圆肯定是用四个矩形拼接在一起的,每个矩形内有圆的1/4图案,
这样4个图案组合在一起就会用重叠的区域,如果点击到重叠区域事件怎么响应能不能缩小点击区域呢?把重叠的部分点击区域忽略掉

解决方案 »

  1.   

    已经搞定了,package com.example.touchdelegatetest;import android.os.Bundle;
    import android.util.Log;
    import android.view.TouchDelegate;
    import android.view.View;
    import android.widget.TextView;
    import android.widget.Toast;
    import android.app.Activity;
    import android.graphics.Rect;public class TouchDelegateTest extends Activity {    @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            View mParent = findViewById(R.id.layout1);
            
            mParent.post(new Runnable() {
                @Override
                public void run() {
                    Rect bounds = new Rect();
                    TextView textView = (TextView) findViewById(R.id.text);
                    textView.setEnabled(true);
                    textView.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View view) {
                            Toast.makeText(TouchDelegateTest.this, "Test TouchDelegate", Toast.LENGTH_SHORT).show();
                        }
                    });
             
                    textView.getHitRect(bounds);
                    
                    Log.e("########", bounds.toString());
                    
                    bounds.inset(50, 50);//整数矩形区域缩小,负数矩形区域放大,上下左右各放大或者缩小给定的值(第一个数字左右,第二个上下)
                                    Log.e("########", bounds.toString());
                    
                    
                    TouchDelegate touchDelegate = new TouchDelegate(bounds, textView);
             
                    if (View.class.isInstance(textView.getParent())) {
                        ((View) textView.getParent()).setTouchDelegate(touchDelegate);
                    }
                }
            });
        }
        
    }就是这些
      

  2.   

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        
    <LinearLayout
        android:id="@+id/layout1"
            android:layout_width="fill_parent"
            android:layout_height="200dip"
            android:orientation="vertical"
            android:background="#FF0000"> <TextView
        android:id="@+id/text"
        android:layout_width="200px"
        android:layout_height="200px"
        android:text="dsfsdfsda"
        android:background="#00FF00"
        android:layout_gravity="center"
        android:layout_marginTop="10px"
        android:textSize="20sp" />
         
        </LinearLayout>
        
      </RelativeLayout>