java - Android Popup Menu fill parent -


i try set popup menu in way fill hole item on grid. on attached first picture , next 1 effect have.

enter image description here

enter image description here

my code:

private void showpopupmenu(view view) {     // inflate menu     contextthemewrapper ctw = new contextthemewrapper(context, r.style.popupmenu);      popupmenu popup = new popupmenu(ctw, view);      menu menu = popup.getmenu();     menu.add(menu.none, 1, menu.none, "remove");     menu.add(menu.none, 2, menu.none, "block");      popup.setonmenuitemclicklistener(new mymenuitemclicklistener());     popup.show(); } 

could please point me right direction achieve effect project?

demo app requirment using popupwindow. preview

you can add list in or customize according needs. mainactivity

public class mainactivity extends activity {      boolean isclicked = true;     popupwindow popupwindow;     relativelayout relative;     imageview btnclickhere;       public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          relative = (relativelayout) findviewbyid(r.id.relative);         popupwindow = new popupwindow(this);         popupwindow.setcontentview(getlayoutinflater().inflate(r.layout.popup_design, null));         popupwindow.getcontentview().findviewbyid(r.id.textviewa).setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 toast.maketext(mainactivity.this, "popitemclicked", toast.length_long).show();             }         });          btnclickhere = (imageview) findviewbyid(r.id.imageview);         btnclickhere.setonclicklistener(new view.onclicklistener() {              public void onclick(view v) {                 if (isclicked) {                     isclicked = false;                     popupwindow.setheight(relative.getheight());                     popupwindow.setwidth(relative.getwidth());                     popupwindow.showasdropdown(relative, 0, -relative.getheight());                 } else {                     isclicked = true;                     popupwindow.dismiss();                 }             }         });     } } 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     tools:context="com.example.sohailzahid.testapp.mainactivity">      <relativelayout         android:id="@+id/relative"         android:layout_width="150dp"         android:layout_height="150dp"         android:layout_centerhorizontal="true"         android:layout_centervertical="true"         android:background="@color/coloraccent"         tools:layout_editor_absolutex="150dp"         tools:layout_editor_absolutey="150dp">          <imageview             android:id="@+id/imageview"             android:layout_width="24dp"             android:layout_height="24dp"             android:layout_alignparentbottom="true"             android:layout_alignparentend="true"             android:layout_alignparentright="true"             android:src="@android:drawable/arrow_down_float" />     </relativelayout>  </relativelayout> 

popup_design.xml

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="#f93567">      <linearlayout         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:orientation="vertical">          <textview             android:id="@+id/textviewa"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:padding="5dp"             android:text="block"             android:textcolor="#ffffff"             android:textsize="20dp" />          <textview             android:id="@+id/textvsiewa"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:padding="5dp"             android:text="add friends"             android:textcolor="#ffffff"             android:textsize="20dp" />          <textview             android:id="@+id/textviesw"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:padding="5dp"             android:text="remove"             android:textcolor="#ffffff"             android:textsize="20dp" />     </linearlayout>      <imageview         android:id="@+id/imageview"         android:layout_width="24dp"         android:layout_height="24dp"         android:layout_alignparentbottom="true"         android:layout_alignparentend="true"         android:layout_alignparentright="true"         android:layout_margin="10dp"         android:src="@android:drawable/arrow_down_float" />  </relativelayout> 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -