Facebook-esque Popup How-to?

Android Android application is very cool, I can only assume PopupWindow (). I really, really struggle with layouts. Any idea how they implemented popup.xml?

I tried to embed a pair of LinearLayouts. Their border looks like a 9-patch. Is it possible?

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/outerLinear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:background="@drawable/darkGrey" > <TextView android:id="@+id/groupTitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="some text" /> <LinearLayout android:id="@+id/innerLinear" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:background="@drawable/white" android:orientation="vertical" > <ListView android:id="@+id/listView1" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView> </LinearLayout> </LinearLayout> 

Facebook Friend Requests Popup

+4
source share
3 answers

You have an Android issue that gives an example of iOS. The Facebook application uses its own iOS look, you can do something like this using a web view with Bootstrap from Twitter .

Take a look at Popovers .

+1
source

I am trying to do the same, and I think I was able to restore it. The first task was to determine which object they are using (I think this is a custom dialog). Ok, then just play around with positioning and other aspects, and I'll go there. I'm not sure about the aspect of 9 patches, but I start with a custom dialog with your layout and then configure the following options.

 //create your dialog Dialog popup = new Dialog(this); //remove title bar popup.requestWindowFeature(Window.FEATURE_NO_TITLE); //set the layout resource popup.setContentView(R.layout.custom_dialog); //can be canceled popup.setCancelable(true); //touch outside of dialogue cancels popup.setCanceledOnTouchOutside(true); //set background to transparent instead of normal black popup.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); //grab the layout params WindowManager.LayoutParams lp = popup.getWindow().getAttributes(); //move the popup to desired location lp.y -= 160/lp.height; lp.x -= 70/lp.width; //remove the dim effect lp.dimAmount = 0; //set new params popup.getWindow().setAttributes(lp); //show the custom dialog popup.show(); 
0
source

I realized this by giving the background of the xml list a 9-patch image and including it in the main xml where it was needed, and then after filling out the list, I switched the visibility when it was needed ... Also canceled during suppression to make the list go away if it was visible and did not exit the application ...

0
source

Source: https://habr.com/ru/post/1389174/


All Articles