2012-01-03 25 views
4

Facebook的Android應用程序有一個非常酷的,我只能假設,PopupWindow()。我真的很擔心佈局。任何想法他們如何實現popup.xml?Facebook式的彈出式操作方法?

我試過嵌套一些LinearLayouts。他們的邊框看起來像一個9貼片可繪製的。這甚至有可能嗎?

<?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

+0

谷歌+ QuickActions? – Selvin 2012-01-04 00:29:34

+0

你可以查看這個http://stackoverflow.com/a/34194097/2022000 – 2015-12-10 05:11:57

回答

1

你有一個Android的問題同時給出iOS的例子。 Facebook應用使用iOS原生視圖,您可以使用帶有Bootstrap from Twitter的網頁視圖來做類似的事情。請看Popovers

+0

我做了一個快速搜索,找不到Facebook的Popup的Android屏幕截圖,但它在Android上幾乎完全相同。不使用WebView。 – 2012-01-04 00:07:40

+0

我不知道Android使用的是什麼,如果它不是WebView。 – Dimme 2012-01-04 00:19:27

+4

Android拇指:http://imageshack.us/photo/my-images/9/facebookandroid.png/這就是你想要的嗎? – sfratini 2012-01-04 00:24:40

0

我正在嘗試做同樣的事情,我想我已經能夠對其進行反向工程。首要任務是確定他們正在使用什麼樣的對象(我認爲這是一個自定義對話框)。好吧,然後只是玩弄定位和其他方面,並在那裏轟炸。我不知道的9補丁方面,但開始使用自定義對話框,你的佈局設置,然後配置下列選項

//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

我也沒有放棄。我已經閱讀了關於具有透明視圖背景和自定義對話框的浮動活動窗口,而且我實際上正在使用主題爲對話框的活動。我甚至給了PopupWindow()一下子沒有太大的成功。我今晚會看看你的實施情況,因爲目前我所定下的那個並不完美。 – 2012-01-16 15:36:23

+0

好@BillMote祝你好運。我一直在使用它,它對我來說工作得很好。 – MikeIsrael 2012-01-16 16:38:07

0

我通過給列表中的XML 9塊圖像的背景來實現這一點,包括它到主要的XML中,需要的地方,然後填充列表後,我需要時切換可見性...也overrided onbackpressed爲了使列表不見了,如果它是可見的,不退出應用程序...

相關問題