Jeremy
Jeremy

Reputation: 3809

Why is layout not appearing in Android?

I cannot figure out why nothing is appearing with my code. Everything is set using a linearlayout, which I am accustomed to yet nothing takes effect when the code is compiled and run. (No errors in the log either) I'm sure I'm just looking over something simple.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    android:background="#000000" >

    <LinearLayout
        android:id="@+id/itemprofilelayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="100"
        android:orientation="vertical"
        android:background="@android:color/transparent" >

        <LinearLayout
            android:id="@+id/toplayout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="30"
            android:orientation="horizontal" 
            android:background="@android:color/transparent" >

            <ImageView
                android:id="@+id/itempicture"
                android:contentDescription=" "
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:background="#FFFFFF"
                android:src="@drawable/budlight_sample" />

            <TextView
                android:id="@+id/iteminformation"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:background="#FFFFFF" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/middlelayout"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="30"
            android:orientation="horizontal" 
            android:background="@android:color/transparent" >

            <TextView
                android:id="@+id/socialoptions"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:background="#FFFFFF"/>

            <TextView
                android:id="@+id/map"
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:background="#FFFFFF" />
        </LinearLayout>

        <TextView
            android:id="@+id/itemratings"
            android:layout_width="fill_parent"
            android:layout_height="15dp"
            android:layout_weight="1"
            android:background="#FFFFFF" />

        <TextView
            android:id="@+id/itemreviews"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="25"
            android:background="#FFFFFF" />

    </LinearLayout>

</ScrollView>

Activity:

package My.Taste.App;

import android.app.Activity;
import android.os.Bundle;

public class ItemListActivity extends Activity{
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.itemlist);
    }
}

Upvotes: 0

Views: 106

Answers (2)

Jeremy
Jeremy

Reputation: 3809

Solved the problem by changing the top half of the code with the following:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/itemprofilestartup"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000000"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/toplayout"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="30"
        android:background="@android:color/transparent"
        android:gravity="top"
        android:orientation="horizontal"
        android:paddingLeft="0dp" >

Upvotes: 0

Sam
Sam

Reputation: 86948

I have never used a MapView. But it is not a standard Android View, try using the full name:

<com.google.android.maps.MapView
    ... />

But if this isn't the problem you also have many of your layout_width attributes set to 0dp. When I changed the width of your ImageView to wrap_content it displayed fine. Also you won't see any of your TextView's because you haven't passed them any text yet.

Upvotes: 4

Related Questions