缩小点击区域怎么实现 一个圆形区域,圆的1/4处即上下左右各有一个按钮(即圆的1/4图片),圆肯定是用四个矩形拼接在一起的,每个矩形内有圆的1/4图案,这样4个图案组合在一起就会用重叠的区域,如果点击到重叠区域事件怎么响应能不能缩小点击区域呢?把重叠的部分点击区域忽略掉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 已经搞定了,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); } } }); } }就是这些 <?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> 学android看哪个老师的视频比较好? 菜单键和返回键冲突 viewgroup 如何与adapter一同使用。。 请教android发送短信的问题 adb push成功了却没有看到应用 頁面跳轉 Android中Bundle取数据空指针异常求解! eclipse开发安卓,进入Debug后怎么关闭 setContentView(R.layout.main) 可以动态实现吗? 莫名的错误android.widget.LinearLayout$LayoutParams ListView 如果做到一个控件内容更新, 其他ListView 条目不更新 ? phonegap
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);
}
}
});
}
}就是这些
<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>