开发者

Where's my ImageViews?

开发者 https://www.devze.com 2023-03-09 09:02 出处:网络
I\'ve got a horizontal LinearLayout (inside of another LinearLayout) containing a few ImageViews. For some reason I\'m just just not seeing them when I run the app.

I've got a horizontal LinearLayout (inside of another LinearLayout) containing a few ImageViews. 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="ce开发者_JAVA百科nter_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? LinearLayouts are horizontal by default. This might be happening because Android is trying to draw the ImageViews to the right of the TextView when I'm guessing you want them below it. 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).


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


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消