为什么列表/滚动视图不填充父级?
|
我在这里遵循一些说明:http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html
我下面的示例全屏显示列表。那就是我要我做的。我究竟做错了什么?
示例结果:
我的结果:
我遵循的示例使用了2个xml布局。 1页面。清单1。
这页纸:
<?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\">
<LinearLayout
android:orientation=\"vertical\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
>
<ListView android:id=\"@id/android:list\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:background=\"#000fff\"
android:layout_weight=\"2\"
android:drawSelectorOnTop=\"false\">
</ListView>
<TextView android:id=\"@id/android:empty\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:background=\"#FFff00\"
android:text=\"No data\"
/>
</LinearLayout>
</ScrollView>
这是列表的xml:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<LinearLayout
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"
android:orientation=\"vertical\">
<TextView android:id=\"@+id/tvAccountName\"
android:textSize=\"16sp\"
android:textStyle=\"bold\"
android:textColor=\"#FFFF00\"
android:layout_width=\"fill_parent\"
android:layout_height=\"fill_parent\"/>
<TextView android:id=\"@+id/tvAccountType\"
android:typeface=\"sans\"
android:textSize=\"14sp\"
android:textStyle=\"italic\"
android:layout_width=\"wrap_content\"
android:layout_height=\"wrap_content\"/>
<TextView android:id=\"@+id/tvAccountBalance\"
android:textSize=\"12sp\"
android:textStyle=\"bold\"
android:layout_width=\"wrap_content\"
android:layout_height=\"fill_parent\"/>
</LinearLayout>
这是清单中的条目:
<activity android:name=\".listAccountsPage\"
android:label=\"@string/app_name\"
>
<intent-filter>
<action android:name=\"com.ourcreditunion.ourcumobile.LISTACCOUNTS\" />
<category android:name=\"android.intent.category.DEFAULT\" />
</intent-filter>
</activity>
那我怎么做才能使它不全屏显示呢?
没有找到相关结果
已邀请:
2 个回复
郡晒景沧
如果需要彩色背景,请在RelativeLayout中设置background属性
耐钨徒
在列表视图的声明中。给出的数字遵循一些逆逻辑, 表示它越大,视图越小。