Android图像缩放布局问题

时间:2012-03-10 23:03:35

标签: java android layout imagebutton

我正在尝试设计一个应用程序,需要创建一个非常简单的菜单栏,其中包含一个图像按钮,我为所有分辨率创建了按钮的图像,并为所有不同的分辨率创建了相同高度的图像栏,但是我的问题是必须坐在普通图像顶部的图像按钮总是更高,我无法弄清楚为什么,例如在hdpi下我有菜单栏图像1024x72和另一个图像为按钮72x72但是当渲染时图像按钮总是更大我疯狂试图找到答案任何帮助将不胜感激。

这是我目前无法正常工作的代码

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/layout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_menu_menu_bar"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true" />






<ImageButton
    android:id="@+id/new_convo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/imageView1"
    android:layout_alignParentTop="true"
    android:src="@drawable/ic_menu_new_convo" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:1)

对于菜单栏,LinearLayout是最佳选择。您必须为背景指定渐变或9补丁,然后使用ImageButton。在Android上,无法保证窗口宽度为1024px,因此您必须改变您的思维方式,并以不同于其他移动平台的方式接近UI设计。如果您提供了所需结果的草图,我们可以更好地理解(和帮助)

相关问题