mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 15:34:01 +00:00
Bug 1097193 - Increase close button hit area in tabs panel (r=lucasr)
This commit is contained in:
parent
7925fb0e28
commit
963757124b
@ -12,6 +12,7 @@ import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TypedValue;
|
||||
import android.view.TouchDelegate;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
@ -93,12 +94,21 @@ public class TabsLayoutItemView extends LinearLayout
|
||||
public boolean onPreDraw() {
|
||||
getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
|
||||
final Rect r = new Rect();
|
||||
mCloseButton.getHitRect(r);
|
||||
r.left -= 25;
|
||||
r.bottom += 25;
|
||||
final Rect hitRect = new Rect();
|
||||
mCloseButton.getHitRect(hitRect);
|
||||
|
||||
setTouchDelegate(new TouchDelegate(r, mCloseButton));
|
||||
// Ideally we want the close button hit area to be 40x40dp but we are constrained by the height of the parent, so
|
||||
// we make it as tall as the parent view and 40dp across.
|
||||
final int targetHitArea = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, getResources().getDisplayMetrics());;
|
||||
final View parent = ((View) mCloseButton.getParent());
|
||||
|
||||
|
||||
hitRect.top = 0;
|
||||
hitRect.right = getWidth();
|
||||
hitRect.left = getWidth() - targetHitArea;
|
||||
hitRect.bottom = parent.getHeight();
|
||||
|
||||
setTouchDelegate(new TouchDelegate(hitRect, mCloseButton));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user