在安卓蜂巢弹出/覆盖屏幕 [英] Popup/Overlay screen in android honeycomb

查看:172
本文介绍了在安卓蜂巢弹出/覆盖屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现一个弹出/叠加屏幕喜欢的地方(我真的更关心如何可以放置屏幕,例如,在屏幕的右侧/左侧)在Android地图应用程序(下图)。我可以创建一个活动,并使用对话的主题,这主要是解决我的问题,但它放在中心的屏幕上。有人有什么更好的想法如何,我可以创造一个弹出/叠加屏幕就像在非地图应用程序和地点的地方。屏幕上方/右?我猜他们这样做是与地图叠加。

I would like to achieve a popup/overlay screen like Places (i`m more interested how can i place that screen for example in the right/left side of the screen ) in the android maps application (image below). I can create an activity and use the Dialog theme, this mostly resolve my problem, but it placed center in the screen. Somebody have any better idea how i can create a popup/overlay screen like the places in a non-map application and place to top/right of the screen ?. My guess they did it with map overlays.

推荐答案

好了,这里就是我所做的。我用的FrameLayout叠加一个LinearLayout中,我可以用一个视图填充它。下面是我的code的摘录:

well, here's what I did... I used a FrameLayout to overlay a LinearLayout where I can fill it with a View. Here's an excerpt of my code:

XML:

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">

     <fragment class="com.some.location.to.fragment"
          android:id="@+id/fragment"
          android:layout_width="match_parent"
          android:layout_height="match_parent" />

     <LinearLayout
          android:id="@+id/overlay_pane"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:visibility="gone"
          android:background="@color/transparent">

      </LinearLayout>

</FrameLayout>

然后在我的一些按钮code,我想补充一个视图(在你的情况下,它可以只是对话框的内容)到overlay_pane的LinearLayout。

Then in my code on some button, I would just add a View (in your case it can just be the dialog's contents) to the overlay_pane LinearLayout.

Java的例子:

ViewGroup container = findViewById(R.id.overlay_pane);
container.setVisibility(View.VISIBLE);
container.addView(some_view_you_inflated);

但这种膨胀的观点将有以下背景: @绘制/ dialog_full_holo_light 对于像蜂窝样式漂亮的边框效果。

But this inflated view would have the following background: @drawable/dialog_full_holo_light for a nice border effect like the Honeycomb style.

您可以在您的SDK中的背景绘制在以下文件夹

You can find the background drawable in your SDK in the following folder

your_SDK_dir /平台/ Android为12 /数据/ RES /绘制,华电国际/ dialog_full_holo_light.9.png

your_SDK_dir/platforms/android-12/data/res/drawable-hdpi/dialog_full_holo_light.9.png

所以刚才复制到可绘制。

So just copy that into your drawables.

请注意:您还可以使用dialog_full_holo_dark或任何自定义背景相同的效果

Note: that you can also use the dialog_full_holo_dark or any custom background for the same effect.

我希望帮助:)让我知道如果我不清楚在任何时候

I hope that helps :) Let me know if I was unclear at any point

注意的:而不是使用一个片段,你可以仅仅使用的LinearLayout与match_parent为layout_width和layout_height。然后你将填补与背景的UI的LinearLayout(在这个问题的例子..这将是图)

Note: Instead of using a fragment, you could merely use a LinearLayout with match_parent for both layout_width and layout_height. And then you would fill that LinearLayout with the "background" UI (in the question's example.. that would be the map)

这篇关于在安卓蜂巢弹出/覆盖屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆