android - 按钮与 ListView 的数据重叠

标签 android android-layout android-listview android-layout-weight

我想知道在 Listview 之后创建一个按钮而不为其高度分配任何核心值的可能性。

发生的事情是,当行数超过 14 或 15 时,我的按钮被 Listview 覆盖。对于我的布局,我主要使用 LinearLayout,因为我觉得不太舒服。

我在这里附上我的布局的 xml fragment 和图像。请看一下并留下您的评论和摆脱上述情况的方法。

提前谢谢大家。

布局 xml 文件( fragment )

 <HorizontalScrollView
        android:id="@+id/scroll_full"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/invScanType" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:id="@+id/lay_fullTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:background="#000000"
                android:orientation="horizontal"
                 >

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="105dp"
                    android:layout_height="wrap_content"
                    android:text="@string/itemno"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="150dp"
                    android:layout_height="wrap_content"
                    android:text="@string/description"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:text="@string/pick_seq"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="105dp"
                    android:layout_height="wrap_content"
                    android:text="@string/mseordqty"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="105dp"
                    android:layout_height="wrap_content"
                    android:text="@string/mseshpqty"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="100dp"
                    android:layout_height="wrap_content"
                    android:text="@string/uom"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="120dp"
                    android:layout_height="wrap_content"
                    android:text="@string/mseshipvia"
                    android:textStyle="bold" >
                </TextView>

                <TextView
                    style="@style/textRegular_list"
                    android:layout_width="90dp"
                    android:layout_height="wrap_content"
                    android:text="@string/msecomments"
                    android:textStyle="bold" >
                </TextView>
            </LinearLayout>

            <ListView
                android:id="@+id/lst_msefull"
                style="@style/ListViewAppTheme.White"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                >
            </ListView>

        </LinearLayout>
    </HorizontalScrollView>

    <LinearLayout
        android:id="@+id/lay_mse"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="16dp"
        android:gravity="center_horizontal"
        android:orientation="horizontal" >
 <Button
            android:id="@+id/btn_mseExit"
            style="@style/ButtonAppTheme"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/action_exit_in" />

    </LinearLayout>

布局图片

enter image description here

这里我想限制我的 Listview 高度,以便当 Listview 内容很大时按钮不会重叠。

最佳答案

将所有内容包裹在垂直的 LinearLayout 中。 将 Horizo​​ntalScrollViewheight 设置为 0dp 并将 weight 设置为 1

关于android - 按钮与 ListView 的数据重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32144551/

相关文章:

java - 考虑用户在 Android 应用程序中选择反向时间间隔的用例

android - 为什么RecyclerView的LinearLayoutManager.findFirstVisibleItemPosition()总是返回0?

android - 包装内容不起作用

android - CoordinatorLayout中如何让ViewStub在AppBarLayout下面

Android根据listview id从数据库中获取单行

android - 类扩展 ListActivity "whose id attribute is ' android.R.id.list'"

android - Android POSIX 兼容吗?

android - Activity 启动背后的linux操作是什么? (安卓)

android - 在没有 Layout Inflater 的情况下使用 getView()

Android从上下文菜单上的自定义 ListView 中获取选定的文本