slashdottir
slashdottir

Reputation: 8556

Eclipse can no longer render my android xml layout

eclipse android graphical layout fail

It used to be that my Eclipse Android Graphical Layout editor could render the layout I had made for my app. But I added just one more layout to include a top row of buttons and now it no longer renders at all.

There are no lint errors. No errors reported in logcat or the error console.

I did a clean and rebuild. No errors anywhere in the project.

I upped the settings in my eclipse.ini to allow for more memory availability (system is 64 bit and has 4G ram).

closed and reopened Eclipsed. Shut down machine, restarted.

None of this made a difference.

Is it just too much for the layout editor to handle? Or is it some other problem?

Thank you

Here is a drawing of what I'm trying to achieve:

mockup

Here is my layout xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainWindowLayout"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <LinearLayout
        android:id="@+id/topButtonsLayout"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:orientation="horizontal" >
        <ImageButton
            android:id="@+id/ideaButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/blah"
            android:src="@drawable/ic_idea" />
        <ImageButton
            android:id="@+id/soundsLikeButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/blah"
            android:src="@drawable/ic_soundslike" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/chooserLayout"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:orientation="horizontal" >
        <LinearLayout
            android:id="@+id/leftThingLayout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical" >
            <EditText
                android:id="@+id/ThisTextBox"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="2"
                android:ems="10"
                android:inputType="textMultiLine"
                android:text="@string/this_thing" />
            <LinearLayout
                android:id="@+id/leftChooserLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
                <ImageButton
                    android:id="@+id/preferLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_likeit" />
                <ImageButton
                    android:id="@+id/defineLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_define" />
                <ImageButton
                    android:id="@+id/notLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                   android:contentDescription="@string/blah"
                    android:src="@drawable/ic_dontlike" />
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:id="@+id/rightThingLayout"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:orientation="vertical" >
            <EditText
                android:id="@+id/ThatTextBox"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="2"
                android:ems="10"
                android:inputType="textMultiLine"
                android:text="@string/that_thing" />
            <LinearLayout
                android:id="@+id/rightChooserLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
                <ImageButton
                    android:id="@+id/preferRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_likeit" />
                <ImageButton
                    android:id="@+id/defineRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_define" />
                <ImageButton
                    android:id="@+id/notRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_dontlike" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>·

thank you for any clues

Upvotes: 0

Views: 1281

Answers (2)

slashdottir
slashdottir

Reputation: 8556

Thank you Tor!

graphical layout editor likes it now

Corrected xml - removing the 0dp stuff... Still using linear layouts everywhere...

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

    <LinearLayout
        android:id="@+id/topButtonsLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/ideaButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/blah"
            android:src="@drawable/ic_idea" />
        <ImageButton
            android:id="@+id/soundsLikeButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:contentDescription="@string/blah"
            android:src="@drawable/ic_soundslike" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/chooserLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <LinearLayout
            android:id="@+id/leftThingLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/ThisTextBox"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.75"
                android:ems="10"
                android:inputType="textMultiLine"
                android:text="@string/this_thing" />

            <LinearLayout
                android:id="@+id/leftChooserLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.25" >

                <ImageButton
                    android:id="@+id/preferLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_likeit" />

                <ImageButton
                    android:id="@+id/defineLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_define" />

                <ImageButton
                    android:id="@+id/notLeft"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_dontlike" />

            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:id="@+id/rightThingLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.5"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/ThatTextBox"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.75"
                android:ems="10"
                android:inputType="textMultiLine"
                android:text="@string/that_thing" />

            <LinearLayout
                android:id="@+id/rightChooserLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="0.25" >

                <ImageButton
                    android:id="@+id/preferRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_likeit" />

                <ImageButton
                    android:id="@+id/defineRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_define" />

                <ImageButton
                    android:id="@+id/notRight"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.3"
                    android:contentDescription="@string/blah"
                    android:src="@drawable/ic_dontlike" />

            </LinearLayout>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

Upvotes: 0

Tor Norbye
Tor Norbye

Reputation: 9150

You have android:layout_height="0dp" in a couple of places there. That makes your views basically invisible. If you change the 0dp to match_parent it should work.

(The right time to use 0dp is when you are using weights to do proportional allocation among the children; then the 0dp basically means that the weights will share all available space, rather than the remainder of the intrinsic sizes).

I've just uploaded a fix to make lint flag issues like this, which will hopefully make it much more obvious in the future: https://android-review.googlesource.com/#/c/45683/

-- Tor

Upvotes: 2

Related Questions