Để gỡ lỗi:
Hãy thử sử dụng một TouchDelegate
cho View, bạn có thể chỉ định rect Touch cho sự trao View
Một ví dụ cho thấy làm thế nào để sử dụng TouchDelegate
:
public class TouchDelegateSample extends Activity {
Button mButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.touch_delegate_view);
mButton = (Button)findViewById(R.id.delegated_button);
View parent = findViewById(R.id.touch_delegate_root);
// post a runnable to the parent view's message queue so its run
after
// the view is drawn
parent.post(new Runnable() {
@Override
public void run() {
Rect delegateArea = new Rect();
Button delegate = TouchDelegateSample.this.mButton;
delegate.getHitRect(delegateArea);
delegateArea.top -= 200;
TouchDelegate expandedArea = new TouchDelegate(delegateArea,
delegate);
// give the delegate to an ancestor of the view we're
delegating the
// area to
if (View.class.isInstance(delegate.getParent())) {
((View)delegate.getParent()).setTouchDelegate(expandedArea);
}
}
});
}
}
hitTest()
Xem liệu điểm truy cập đã cho có nằm trong giới hạn của điểm đánh dấu của mục hay không. Ghi đè để sửa đổi cách mục được truy cập thử nghiệm. Điểm nhấn liên quan đến giới hạn của người đánh dấu. Việc triển khai mặc định chỉ kiểm tra xem điểm truy cập có nằm trong giới hạn có thể chạm của điểm đánh dấu hay không.
bạn đã từng giải quyết vấn đề này chưa? –