[英]Why isn't this list/scrollview filling the parent?
I was following some instructions here: http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html我在这里遵循一些说明: http://saigeethamn.blogspot.com/2010/04/custom-listview-android-developer.html
The example I'm following shows the list fullscreen.我下面的示例显示了全屏列表。 That's what I want mine to do.
这就是我想要我做的。 What am I doing wrong?
我究竟做错了什么?
examples result:示例结果:
My result:我的结果:
The example I followed used 2 xml layouts.我遵循的示例使用了 2 个 xml 布局。 1 for the page.
1 为页面。 1 for the list.
1 为列表。
The page:这页纸:
<?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>
And here's the xml for the list:这是列表的 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>
And here's the entry from the manifest:这是清单中的条目:
<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>
So what did I do to cause it to not be full screen?那么我做了什么导致它不是全屏呢?
Like @adamp says - don't put a listview inside a scrollview.就像@adamp 说的那样 - 不要将列表视图放在滚动视图中。 Which one is going go scroll?
go 卷轴是哪一个? Your xml needs to be simpler also.
您的 xml 也需要更简单。 Try something like this:
尝试这样的事情:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView
android:layout_width="match_parent"
android:id="@+id/listView1"
android:layout_alignParentLeft="true"
android:layout_height="match_parent"/>
</RelativeLayout>
If you want a colored background, set the background attribute in the RelativeLayout如果您想要彩色背景,请在 RelativeLayout 中设置背景属性
I think it is coming from this我认为它来自这个
android:layout_weight="2"
in the declaration of the list view.在列表视图的声明中。 The number given follows some inverse logic, meaning that the larger it is, the smaller the view gets.
给出的数字遵循一些逆逻辑,这意味着它越大,视图越小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.