https://github.com/anskya520/BubbleView
public class TestActivity extends AppCompatActivity {
@BindView(R.id.btv1)
BubbleTextView btv1;
@BindView(R.id.tvMe)
Button tvMe;
private BubblePopupWindow mBubblePopupWindow;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
ButterKnife.bind(this);
initView();
}
private void initView() {
/*可以自定义*/
View rootView = LayoutInflater.from(this).inflate(R.layout.simple_text_bubble, null);
BubbleTextView mBubbleTextView = (BubbleTextView) rootView.findViewById(R.id.popup_bubble);
mBubbleTextView.setText("这是个错误");
mBubblePopupWindow = new BubblePopupWindow(rootView, mBubbleTextView);
mBubblePopupWindow.setCancelOnTouchOutside(false);
mBubblePopupWindow.setCancelOnLater(0);
mBubblePopupWindow.setPadding(dp2px(10));
}
int pad = 10;
@OnClick(R.id.iv2)
public void onTestClick() {
btv1.setPadding(pad, pad, pad, pad);
pad++;
}
@OnClick(R.id.tvMe)
public void onMeTestClick() {
if (hasWindowFocus()) {
mBubblePopupWindow.showArrowTo(tvMe, new RelativePos(RelativePos.CENTER_HORIZONTAL, RelativePos.ABOVE), 0, 0);
}
}
}
Snipaste_2021-06-04_08-55-41.png
其他
https://github.com/sephiroth74/android-target-tooltip
本质是public class BubblePopupWindow extends PopupWindow {
popupwindow的使用
网友评论