【问题标题】:How to stretch my listview to scrollview's heigth?如何将我的列表视图拉伸到滚动视图是高度?
【发布时间】:2011-04-29 17:35:10
【问题描述】:

如何在给定的代码中拉伸 listView 以匹配他的祖父母框架(父母 = 线性布局,祖父母 = 滚动视图)。到目前为止,我的列表视图最多只能延伸 3 个项目。 :(

代码如下:

        <ScrollView android:layout_span="2" android:layout_width="fill_parent" android:layout_height="90pt">
            <LinearLayout android:id="@+id/linearLayout1"
                android:orientation="vertical" android:layout_span="2"
                android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:layout_height="match_parent">
                <TextView android:id="@android:id/empty" android:layout_width="wrap_content" android:layout_gravity="center_horizontal" android:typeface="monospace" android:layout_height="0dip" android:text="@string/immu_no_list_data_text" android:layout_weight="1.0" android:textSize="20dp"></TextView>
                <ListView android:layout_weight="1.0" android:layout_width="wrap_content" android:id="@+id/list_immu" android:layout_gravity="center_vertical" android:layout_height="fill_parent"></ListView>

            </LinearLayout>
        </ScrollView>

【问题讨论】:

    标签: android listview scrollview


    【解决方案1】:

    您需要滚动视图的任何特殊原因?

    ListView 和 ScrollView 不能很好地配合使用。列表视图将自行处理滚动。试试:

    <LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent">
       <TextView ... />
       <ListView 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" />
    </LinearLayout>
    

    【讨论】:

    • 只是为了把我的按钮放在屏幕底部!是的!呵呵还有其他想法来构建我的线性布局吗?呵呵。因为我真正的问题是,当动态填充列表时,它会将我的按钮推到屏幕下方,用户无法查看或使用它。:(
    • 您应该添加完整的布局和/或屏幕截图来说明您需要实现的目标。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多