4

I'm trying to use the layout_weight attribute for testing. It works fine excpect for the ListView. I've set the height to 0dp and the weightsum. I've tried to put the ListView into a relative Layout but I get the same result.

Here is my code:

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

<TextView
    android:id="@+id/textView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.25"
    android:text="TextView" />

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.25" >
</ListView>

<TextView
    android:id="@+id/textView2"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.25"
    android:text="TextView" />

<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.25"
    android:text="Button" />

</LinearLayout>

And this is how it looks:

pic

It seems connected to the theme I'm using. I'm using Theme.Black.NoTitleBar Theme. The weird thing is I can see it normal in the emulator but not in the IDE, but I need to see things in the IDE, because I work a lot with the GUI and I'm rarly coding in XML. Is there a fix for this? Is this a known bug?

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • Try putting your ListView in another LinearLayout – Gokhan Arik Jan 23 '14 at 16:08
  • 1
    Do you get this pic from visual editor, real device or emulator? I've checked your layout in empty project and it works as expected on emulator – Dimmerg Jan 23 '14 at 16:10
  • And try to run it on device, it might not look as expected on IDE. It works fine with me. – Gokhan Arik Jan 23 '14 at 16:10
  • The pic is from the layout editor, and it will probably never show you what the list is actually going to look like. You'll have to run the app on a device or emulator to see how it will actually appear. – dm78 Jan 23 '14 at 16:18
  • will do. just a moment – user3146659 Jan 23 '14 at 16:25
  • @user3146659 I think you will get what you expecting if you run this in real device or emulator , because code looks fine. – Kunu Jan 23 '14 at 16:31

1 Answers1

0

You can change the Theme of the IDE in the right top border. It may be that the current theme chosen miss some attrs.

Endzeit
  • 4,810
  • 5
  • 29
  • 52