2011-11-21 19 views
0

我有一個線性佈局與4個圖像水平方向。 ?我的問題是,第一圖像裁剪,我不能看到他們兩個在我的GALAXY S,只有在一些emulators..any幫助,請這是我的線性佈局代碼:LinearLayout與4個圖像 - 我不能看到他們洞

<LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" > 



     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_new_3" 
      android:layout_weight="1" 
       /> 


     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn1"       
       /> 

     <ImageButton   
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn2"     

      /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="fill_parent" 
      android:background="@drawable/header_btn3"       

      /> 
    </LinearLayout> 

這就是我想要的enter image description here

,這就是我得到enter image description here

@Jamo:此搜索:

enter image description here

image2,3,4:

enter image description here

+0

你能給我們提供幫助測試的圖片嗎? –

+0

當然,只需要一秒鐘就可以上傳它們 –

回答

0

你含佈局fill_parent,這意味着它僅限於其父的寬度(可能是整個屏幕)。每個ImageButton設置爲寬度wrap_content,這意味着它只適合其內容的寬度。如果您使用的圖像背景寬度總和超過總寬度,您將遇到問題。這似乎是發生了什麼事。您無法將更多像素放入屏幕中。

更新:

與您提供的圖形時,「你好」的形象是138px和明星爲60像素。 138 + 60 * 3 = 318。如果你的屏幕寬度是480px(我認爲Galaxy S是480寬),那麼你應該能夠適應。如果你把它們放到默認或mdpi文件夾(而Galaxy S是hdpi),那麼這些將被縮放到1.5x,即477px。這應該仍然適合。

+0

所以解決這個問題的唯一方法就是擁有更小的圖形? –

+0

我已經更新了一些快速計算。 LinearLayout是否真的是頂層佈局?或者是否包含在其他內容中? – kabuko

0

我知道要創建類似的東西是使用RelativeLayout的這樣的唯一方法:

<RelativeLayout android:layout_height="wrap_content" 
    android:layout_width="fill_parent"> 
    <ImageView android:layout_alignParentRight="true" 
     android:id="@+id/iv4" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv4" 
     android:id="@+id/iv3" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv3" 
     android:id="@+id/iv2" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/icon"/> 
    <ImageView android:layout_toLeftOf="@id/iv2" 
     android:id="@+id/iv1" 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:src="@drawable/icon"/> 
</RelativeLayout> 
0

我們在先前的問題聊起這一點。請發佈整個佈局文件。如果總寬度受到外部LinearLayout父級的限制,那麼layout_weight不會有太大的作用,正如其他帖子所暗示的那樣。

此外,一些想法。

您對ImageView高度有「fill_parent」。我認爲這些應該是「wrap_content」。你用「背景」而不是「src」來設置圖像,這很奇怪。

此外,該第一個圖像應該在另一個佈局容器,以允許拉伸,不會搞砸'你好'。

<LinearLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 


    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:orientation="horizontal" 
     android:layout_weight="1"> 
     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/header_new_3" 
      android:layout_gravity="center" 
      /> 
    </LinearLayout> 

不是100%確定這正是你想要的,但最終目標是拉伸第一張圖片而不以任何方式剪切。

相關問題