2011-08-31 27 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