I achieved this behavior using PopUpWindow, here is my code:
private void showStatusPopup(final Activity context, Point p) {
LinearLayout viewGroup = (LinearLayout) context.findViewById(R.id.llStatusChangePopup);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.status_popup_layout, null);
changeStatusPopUp = new PopupWindow(context);
changeStatusPopUp.setContentView(layout);
changeStatusPopUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
changeStatusPopUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
changeStatusPopUp.setFocusable(true);
int OFFSET_X = -20;
int OFFSET_Y = 50;
changeStatusPopUp.setBackgroundDrawable(new BitmapDrawable());
changeStatusPopUp.showAtLocation(layout, Gravity.NO_GRAVITY, p.x + OFFSET_X, p.y + OFFSET_Y);
}
and this is the layout of PopUp:
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/devider_popup_task_status_change"
android:contentDescription="@drawable/devider_popup_task_status_change"/>
<TextView
android:id="@+id/tvInProgress"
android:paddingLeft="10dp"
android:layout_weight="1.0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/my_black"
android:gravity="center_vertical"
android:clickable="true"
android:onClick="popupStatusChangeOnClick"
android:layout_marginLeft="11dp"
android:layout_marginRight="4dp"
android:text="@string/inprogress"/>
<ImageView
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/devider_popup_task_status_change"
android:contentDescription="@drawable/devider_popup_task_status_change"/>
<TextView
android:id="@+id/tvOnTheWay"
android:paddingLeft="10dp"
android:layout_weight="1.0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/my_black"
android:gravity="center_vertical"
android:clickable="true"
android:onClick="popupStatusChangeOnClick"
android:layout_marginLeft="11dp"
android:layout_marginRight="4dp"
android:text="@string/ontheway"/>
<ImageView
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/devider_popup_task_status_change"
android:contentDescription="@drawable/devider_popup_task_status_change"/>
<TextView
android:id="@+id/tvComplete"
android:paddingLeft="10dp"
android:layout_weight="1.0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/my_black"
android:gravity="center_vertical"
android:clickable="true"
android:onClick="popupStatusChangeOnClick"
android:layout_marginLeft="11dp"
android:layout_marginRight="4dp"
android:text="@string/complete"/>
<ImageView
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/devider_popup_task_status_change"
android:contentDescription="@drawable/devider_popup_task_status_change"/>
<TextView
android:id="@+id/tvFailed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:layout_weight="1.0"
android:gravity="center_vertical"
android:clickable="true"
android:onClick="popupStatusChangeOnClick"
android:layout_marginLeft="11dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="11dp"
android:text="@string/failed"
android:textColor="@color/my_black" />
When ImageVieware only 1 pixel-deviders.
source
share