2014-05-12 86 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像素之前。