Bug 1098459 - Remove dead area on the right of "new tab" button (r=mcomella)

This commit is contained in:
Lucas Rocha 2014-11-24 14:06:26 +00:00
Родитель ce9855e1b3
Коммит eccb65d5a0
2 изменённых файлов: 24 добавлений и 0 удалений

Просмотреть файл

@ -12,6 +12,8 @@
android:layout_weight="1"
android:paddingTop="4dp"/>
<!-- The right margin creates a "dead area" on the right side of the button
which we compensate for with a touch delegate. See TabStrip -->
<ImageButton
android:id="@+id/add_tab"
style="@style/UrlBar.ImageButton"

Просмотреть файл

@ -6,9 +6,12 @@
package org.mozilla.gecko.tabs;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.TouchDelegate;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.ImageButton;
import org.mozilla.gecko.R;
@ -51,6 +54,25 @@ public class TabStrip extends ThemedLinearLayout {
}
});
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
final Rect r = new Rect();
r.left = addTabButton.getRight();
r.right = getWidth();
r.top = 0;
r.bottom = getHeight();
// Redirect touch events between the 'new tab' button and the edge
// of the screen to the 'new tab' button.
setTouchDelegate(new TouchDelegate(r, addTabButton));
return true;
}
});
tabsListener = new TabsListener();
}