mirror of
https://github.com/Tencent/QMUI_Android.git
synced 2026-10-17 04:31:16 +08:00
feat: expendTouchArea
This commit is contained in:
@@ -13,7 +13,7 @@ object Dep {
|
||||
|
||||
object QMUI {
|
||||
const val group = "com.qmuiteam"
|
||||
const val qmuiVer = "2.1.0.26"
|
||||
const val qmuiVer = "2.1.0.27"
|
||||
const val archVer = "2.1.0.4"
|
||||
const val typeVer = "0.1.0.8"
|
||||
|
||||
|
||||
@@ -126,6 +126,25 @@ public class QMUIViewHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public static void expendTouchArea(final View view, final int left, final int right, final int top, final int bottom) {
|
||||
if (view != null) {
|
||||
final View parentView = (View) view.getParent();
|
||||
|
||||
parentView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Rect rect = new Rect();
|
||||
view.getHitRect(rect); //如果太早执行本函数,会获取rect失败,因为此时UI界面尚未开始绘制,无法获得正确的坐标
|
||||
rect.left -= left;
|
||||
rect.top -= top;
|
||||
rect.right += right;
|
||||
rect.bottom += bottom;
|
||||
parentView.setTouchDelegate(new TouchDelegate(rect, view));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
public static void setBackground(View view, Drawable drawable) {
|
||||
|
||||
Reference in New Issue
Block a user