2014-05-12 85 views
0

我遇到了兩個ImageViews的問題,它們在layout.xml中顯示,但在運行應用程序時沒有顯示。Android ImageView不顯示

<?xml version="1.0" encoding="utf-8"?> 
<!-- Outter Linear Layout --> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/linearOutter" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="#e6e6e9" > 

<!-- First inner Linear Layout --> 
<LinearLayout 
android:id="@+id/linearInner1" 
android:layout_width="fill_parent" 
android:layout_height="0dp" 
android:layout_weight="0.18" 
android:paddingLeft="16dp" 
android:paddingRight="16dp" 
android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/moyland_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/moyland" /> 

    <ImageView 
     android:id="@+id/hsrw_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/hsrw" /> 

</LinearLayout> 

<!-- Title --> 

<org.hsrw.artandcycle.util.AutoResizeTextView 
    android:id="@+id/widget37" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.1" 
    android:fontFamily="sans-serif-thin" 
    android:gravity="center" 
    android:text="@string/app_name_upper" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textColor="#0C1273" 
    android:maxLines="1" 
    android:textSize="100sp" /> 

<!-- Second inner Linear Layout --> 

<LinearLayout 
    android:id="@+id/linearInner2" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.18" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/gelderland_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/erfgoed_gelderland" /> 

    <ImageView 
     android:id="@+id/interreg_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/interreg" /> 
</LinearLayout> 

<!-- Third inner Linear Layout --> 

<LinearLayout 
    android:id="@+id/linearInner3" 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.18" 
    android:orientation="horizontal" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" > 

    <ImageView 
     android:id="@+id/erw_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/erw" /> 

    <ImageView 
     android:id="@+id/gelderland2_logo" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.5" 
     android:gravity="center" 
     android:src="@drawable/province_gelderland" /> 
</LinearLayout> 

<ImageView 
    android:id="@+id/foerder_logo" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.18" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:gravity="center" 
    android:src="@drawable/foerder" /> 

<ImageView 
    android:id="@+id/wfg_logo" 
    android:layout_width="fill_parent" 
    android:layout_height="0dp" 
    android:layout_weight="0.18" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:gravity="center" 
    android:src="@drawable/wfg" /> 

</LinearLayout> 

這是我的佈局。所有內容都按原樣顯示,但最後兩個圖像視圖不顯示在我的Galaxy Nexus上。

我做錯了什麼?

+0

您確定屏幕上有足夠的空間來顯示所有圖像嗎?由於您的根視圖是垂直方向的LinearLayout,因此可能是您的ImageView的最後一行「行」超出了屏幕。 此外,我不知道你在那裏做什麼,但也許問題是在android:layout_height =「0dp」。 –

+0

感謝您的回覆。高度設置爲0dp,因爲重量可以處理比例。就像上面的圖片一樣。所有權重的總和爲1,涉及外部線性佈局。 – MarcoMeter

+0

即使我在加權0.7的TextView之後只使用一個ImageView,也不會顯示此視圖的圖像。 – MarcoMeter

回答

0

問題是最後兩張圖片的尺寸。

我將這些圖像的寬度縮小到800.在寬度約爲1300像素之前。