4

我正在尝试使用 layout_weight 属性进行测试。它适用于 ListView。我已将高度设置为 0dp 和 weightsum。我试图将 ListView 放入相对布局中,但我得到了相同的结果。

这是我的代码:

<?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>

这就是它的外观:

图片

它似乎与我正在使用的主题有关。我正在使用Theme.Black.NoTitleBar主题。奇怪的是我可以在模拟器中正常看到它,但在 IDE 中看不到,但我需要在 IDE 中看到,因为我经常使用 GUI,而且我很少使用 XML 编码。有解决办法吗?这是一个已知的错误?

4

1 回答 1

0

您可以在右上边框更改 IDE 的主题。可能是当前选择的主题错过了一些属性。

于 2014-01-23T16:54:18.430 回答