简体   繁体   English

我的 ImageViews 在哪里?

[英]Where's my ImageViews?

I've got a horizontal LinearLayout (inside of another LinearLayout ) containing a few ImageView s.我有一个水平LinearLayout (在另一个LinearLayout内),其中包含一些ImageView For some reason I'm just just not seeing them when I run the app.出于某种原因,我只是在运行应用程序时没有看到它们。

Here's my layout:这是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:background="@drawable/background">
    <TextView android:layout_height="wrap_content"
        android:layout_width="wrap_content" android:textSize="20dp"
        android:text="A bunch of text"
        android:textColor="#000000" android:layout_gravity="center_horizontal"
        android:padding="10dp" android:background="#0000FF"/>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_height="wrap_content" android:layout_width="fill_parent"
        android:orientation="horizontal">

        <ImageView android:layout_width="wrap_content"
        android:layout_height="75dp"
             android:src="@drawable/image1"
            android:scaleType="centerCrop" android:background="#0000FF"/>
        <ImageView android:layout_width="wrap_content" android:layout_height="75dp"
            android:layout_weight="1" android:src="@drawable/image2"
            android:scaleType="centerCrop" />
        <ImageView android:layout_width="wrap_content" android:layout_height="75dp"
            android:layout_weight="1" android:src="@drawable/image3"
            android:scaleType="centerCrop" />
    </LinearLayout>
</LinearLayout>

I take it that you can see the TextView then?我认为您可以看到TextView那么? LinearLayout s are horizontal by default. LinearLayout默认是水平的。 This might be happening because Android is trying to draw the ImageView s to the right of the TextView when I'm guessing you want them below it.这可能是因为 Android 试图将TextView绘制到ImageView的右侧,而我猜你想要它们在它下面。 Try adding android:orientation="vertical" to the outer LinearLayout and removing android:orientation="horizontal" from the inner LinearLayout (well, you don't need to remove it).尝试将android:orientation="vertical"添加到外部LinearLayout并从内部LinearLayout中删除android:orientation="horizontal" (嗯,您不需要删除它)。

try to change the android:orientation of your LinearLayout to vertical and it will fixe the problem, because the orientation horizontal, it pisses the imageviews out of the screen尝试将android:orientation of your LinearLayout更改为vertical ,它会解决问题,因为方向水平,它会惹恼屏幕上的图像视图

Not sure how you want to layout your view, your code looks okay to me, at least those imageviews should show up.不知道你想如何布局你的视图,你的代码对我来说看起来不错,至少那些图像视图应该显示出来。 Are you sure your image sources ( image1, image2.. ) are not just some plain colors that are same as background color?您确定您的图像源( image1, image2.. )不只是一些与背景颜色相同的普通 colors 吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM