【问题标题】:Facebook-esque Popup How-to?Facebook 式的弹出窗口操作方法?
【发布时间】:2012-02-01 23:12:48
【问题描述】:

Facebook Android 应用程序有一个非常酷的,我只能假设,PopupWindow()。我真的,真的很纠结于布局。知道他们是如何实现 popup.xml 的吗?

我尝试过嵌套几个 LinearLayout。它们的边框看起来像一个 9-patch 可绘制对象。这可能吗?

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

【问题讨论】:

标签: android facebook android-layout popupwindow nine-patch


【解决方案1】:

在给出 iOS 示例时,您有一个 Android 问题。 Facebook 应用程序使用 iOS 原生视图,您可以使用带有 Bootstrap from Twitter 的 Web 视图执行类似操作。

看看他们的Popovers

【讨论】:

  • 我快速搜索并找不到 Facebook 弹出窗口的 Android 屏幕截图,但它在 Android 上几乎相同。不使用 WebView。
  • 如果不是 WebView,我不知道 Android 正在使用什么。
  • 安卓拇指:imageshack.us/photo/my-images/9/facebookandroid.png这就是你想要的吧?
【解决方案2】:

我正在尝试做同样的事情,并且我认为我已经能够对其进行逆向工程。第一个任务是确定他们正在使用什么样的对象(我认为这是一个自定义对话框)。好的,然后就在定位和其他方面进行调整,然后就可以了。我不确定 9-patch 方面,但从带有布局集的自定义对话框开始,然后配置以下选项

//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();

【讨论】:

  • 我也没有放弃。我已经阅读了有关具有透明视图背景、自定义对话框的浮动活动窗口的信息,并且我现在实际上正在使用以对话框为主题的活动。我什至尝试了 PopupWindow(),但没有取得多大成功。今晚我会看看你的实现,因为我目前确定的那个并不完美。
  • 好的 @BillMote 祝你好运。我一直在使用它,它对我来说效果很好。
【解决方案3】:

我通过为列表 xml 的背景提供一个 9 补丁图像并将其包含在需要的主 xml 中来实现这一点,然后在填充列表后,我在需要时切换了可见性...还覆盖了 onbackpressed 以如果列表可见且不退出应用程序,则使列表消失...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多