Merge "Adding tooltip for Select button." into ub-launcher3-rvc-dev

This commit is contained in:
TreeHugger Robot 2020-06-11 21:07:39 +00:00 committed by Android (Google) Code Review
commit 8449aeaf6e
2 changed files with 27 additions and 4 deletions

View File

@ -60,6 +60,5 @@
android:elevation="2dp"
android:layout_width="10dp"
android:layout_height="8dp"
android:layout_marginTop="-2dp"
android:layout_gravity="center_horizontal"/>
android:layout_marginTop="-2dp"/>
</merge>

View File

@ -125,11 +125,35 @@ public class ArrowTipView extends AbstractFloatingView {
* Show Tip with specified string and Y location
*/
public ArrowTipView show(String text, int top) {
return show(text, Gravity.CENTER_HORIZONTAL, 0, top);
}
/**
* Show the ArrowTipView (tooltip) center, start, or end aligned.
*
* @param text The text to be shown in the tooltip.
* @param gravity The gravity aligns the tooltip center, start, or end.
* @param arrowMarginStart The margin from start to place arrow (ignored if center)
* @param top The Y coordinate of the bottom of tooltip.
* @return The tooltip.
*/
public ArrowTipView show(String text, int gravity, int arrowMarginStart, int top) {
((TextView) findViewById(R.id.text)).setText(text);
mActivity.getDragLayer().addView(this);
ViewGroup parent = mActivity.getDragLayer();
parent.addView(this);
DragLayer.LayoutParams params = (DragLayer.LayoutParams) getLayoutParams();
params.gravity = Gravity.CENTER_HORIZONTAL;
params.gravity = gravity;
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) findViewById(
R.id.arrow).getLayoutParams();
lp.gravity = gravity;
if (gravity == Gravity.END) {
lp.setMarginEnd(parent.getMeasuredWidth() - arrowMarginStart);
} else if (gravity == Gravity.START) {
lp.setMarginStart(arrowMarginStart);
}
requestLayout();
params.leftMargin = mActivity.getDeviceProfile().workspacePadding.left;
params.rightMargin = mActivity.getDeviceProfile().workspacePadding.right;
post(() -> setY(top - getHeight()));