Hãy thử mã mẫu này. Nó phù hợp với yêu cầu của bạn.
PopupWindow pw = new PopupWindow(
this.getViewInflate().inflate(R.layout.pw_layout,
null, true, null),
100,100,true);
// display the popup in the center
pw.showAtLocation(layout, Gravity.CENTER, 0, 0);
pw.update(20,20,100,100);
Đối với chế độ xem bên trong EditText
một phần, bạn sẽ phải gia hạn EditText
. Tổng quan về cách nó sẽ trông như sau.
class emailEditText extends EditText {
List<NamePhotoView> ViewlistOfSelectedContacts; // create new
void addContact(String name, Bitmap photo) {
// create a new 'NamePhotoView' and add to the ViewlistOfSelectedContacts
}
@Override
void onDraw(Canvas canvas) {
for (....) {
// draw all views from the list. left to right.
}
// you have to some how offset the text start coordinate. then call super
super.onDraw(canvas);
}
}
Điều đó không giống như một bản xem trước đơn giản bên trong văn bản chỉnh sửa .. Loại xem 'PopupWindow' của nó là – Ronnie