ListView layout_weight不起作用,高度设置为0dp [英] ListView layout_weight not working, height set to 0dp
问题描述
我正在尝试使用layout_weight属性进行测试.它对ListView的工作效果很好.我已将高度设置为0dp,并设置了weightsum.我试图将ListView放入相对的Layout中,但得到的结果相同.
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.
这是我的代码:
<?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进行编码.有没有解决的办法?这是一个已知的错误吗?
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?
推荐答案
您可以在右上边框更改IDE的主题.可能是当前选择的主题缺少一些属性.
You can change the Theme of the IDE in the right top border. It may be that the current theme chosen miss some attrs.
这篇关于ListView layout_weight不起作用,高度设置为0dp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!