Facebook 风格的弹出窗口如何操作?
我只能假设 Facebook Android 应用程序有一个非常酷的 PopupWindow()。我真的非常非常纠结于布局。知道他们是如何实现 popup.xml 的吗?
我尝试过嵌套几个 LinearLayout。它们的边框看起来像一个 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>
The Facebook Android app has a very cool, I can only assume, PopupWindow(). I really, really struggle with layouts. Any idea how they implemented the popup.xml?
I've tried nesting a couple of LinearLayouts. Their border looks like a 9-patch drawable. Is that even 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您在给出 iOS 示例时遇到了 Android 问题。 Facebook 应用程序使用 iOS 本机视图,您可以使用 Web 视图执行类似的操作 Bootstrap from Twitter 。
看看他们的 Popovers。
You have an Android question while giving an iOS example. The Facebook app uses an iOS native view, you may do something similar using a web view with Bootstrap from Twitter.
Take a look at their Popovers.
我正在尝试做同样的事情,并且我认为我已经能够对其进行逆向工程。第一个任务是确定他们使用的对象类型(我认为这是一个自定义对话框)。好的,然后尝试一下定位和其他方面,然后就可以了。我不确定 9 补丁方面,但从带有布局集的自定义对话框开始,然后配置以下选项
I am trying to do the same thing, and I think I have been able to revers engineer it. First task was identifying what kind of object they were using (I think it is a custom dialog). OK then just play around with positioning and other aspects and bang there ya go. I am not sure about the 9-patch aspect but start with a custom dialog with your layout set and then configure the following options
我通过为列表 xml 的背景提供一个 9 补丁图像并将其包含到需要的主 xml 中来实现此目的,然后在填充列表后,我在需要时切换可见性...还覆盖了 onbackpressed 以便制作列表如果它可见并且不退出应用程序,则消失...
I implemented this by giving the background of the list xml a 9-patch image and including it into the main xml where was needed and then after populating the list I toggled the visibility when needed... Also overrided onbackpressed in order to make the list gone if it was visible and not exit the application...