如何放置的透明按钮在图像比较? [英] How to place transparent buttons over an image relatively?

查看:132
本文介绍了如何放置的透明按钮在图像比较?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找在Android中的方式如何把一些透明的按钮在一个(背景)图像,使我有很好的控制来定位按钮和他们留是他们的意思是,如果同时在屏幕大得多。

I am looking for a way in Android how to place some transparent buttons over a (background)image so i have good control to position the buttons and they stay were they meant to be also if the screen is much larger.

正如你所能想象的形象也包含该按钮的艺术......

As you can imagine the image contains also the button art...

最好的事情是,如果我可以用百分比定位按钮,但可悲的是,这是不可能的机器人。

The best thing would be if I could position the buttons by using percentage, but sadly this is not possible in android.

这是我目前的code的基础:

This is my current base of the code:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/art_main_background" >

作为替代方案,我也可以提取按钮,艺术,并将其放置在图像上,但是这会导致同样的问题,我怎么能控制好仓位,如果按钮是不是在线性一种秩序,即相当随机的。

As an alternative, I could also extract the button art and place them over the image, but this would lead to the same problem, how can I control the position if the buttons are not in a 'linear' kind of order, i.e. rather random.

推荐答案

您绝对应该做的按钮,单独的艺术作品,将它们作为ImageButtons。您可以使用的FrameLayout堆叠它们放在图像上(实际上,如果它设置为背景图片,你应该甚至不需要的FrameLayout),但我认为你必须比这更问题,如果我理解正确。

You should definitely make the button art separate pieces, and then place them in as ImageButtons. You can use a FrameLayout to stack them on top of the image (actually, if it's set as a background image, you shouldn't even need the FrameLayout) but I think you'll have more problems than that if I understand you correctly.

您试图使一个单一的形象,你的控制,只是按键映射到特定的位置?考虑到屏幕分辨率和尺寸变化的数字,这只是在Android是一个坏主意。考虑重新思考布局更灵活一点。如果您确实需要绝对定位,你可以使用的FrameLayout,只是指定左边和顶部边缘放置它们,但要记住什么可能完全适合于一个分辨率不一定适合其他正常。

Are you trying to make a single image as your controls, and just map buttons to specific positions? Considering the number of variations in screen resolutions and sizes, this is just a bad idea on Android. Consider rethinking your layout to be a bit more flexible. If you do need absolute positioning, you can use a FrameLayout, and just specify left and top margins to position them, but keep in mind what might fit perfectly on one resolution won't necessarily fit into another properly.

如果你可以张贴的你心里已经有了一个什么样,我们也许能够给你一些想法。

If you can post a sample of what you've got in mind, we might be able to give you some ideas.

这篇关于如何放置的透明按钮在图像比较?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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