2011-08-31 30 views
0

我是相当新的整个Android的东西,所以我希望这是明显的东西,我忽略了,因为我还没有能够找到一个在线解决方案。布局与图像和“底部栏”问题

我正在创建一个包含ImageView和“底部栏”的视图。我遇到的问题是,由于图像比屏幕大,我宁愿使用类似于“fill_parent”或“wrap_content”的东西。理想情况下,我会将ImageView的高度设置为“fill_parent-44px”,但我还没有找到在XML中执行此操作的方法。

最终我计划使用多点触控缩放的ImageView功能,因此它不是为不同屏幕分辨率调整图像大小的选项。

感谢您的任何帮助。

+0

请张贴的布局代码。 –

回答

2

很容易与RelativeLayout做到这一点:

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

    <View android:id="@+id/bottombar" 
     android:background="#FFCC00" 
     android:layout_height="40dp" 
     android:layout_width="fill_parent" 
     android:layout_alignParentBottom="true" /> 

    <ImageView android:id="@+id/image" 
     android:src="@drawable/someimage" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@id/bottombar"/> 

</RelativeLayout> 

这里最重要的事情是android:layout_alignParentBottomandroid:layout_above(见RelativeLayout.LayoutParams所有可能的布局属性)。

android:layout_height="fill_parent"或多或少地被忽略,因为参数的权利RelativeLayout,它只是需要在那里取悦Android UI系统。

android:background只是在UI设计突出,并且bottombarView可以通过像,TextViewLinearLayout任何其他视图替换等

+0

谢谢,那正是我希望实现的目标 – orpheus