0

这很奇怪。我有一组选项卡,其中一个(实际上是两个,但它们是同一件事,内容略有不同)正在发挥作用。我有两个 XML 文件。一个是用于景观的,它工作得很好。另一个是肖像,它行为不端。下面我将附上xml。页面的设置方式,它有一个线性布局作为根布局。然后是一个包含水平线性布局和相对布局的滚动视图。它们应该相互堆叠。为此,我做了与横向版本相反的操作。我将每个布局的高度设置为 0dp,将重量设置为 1。在横向版本中,这可以正常工作,并且可以按预期将它们隔开。滚动视图具有标记为 true 的填充视图窗口和标记或声明或高度之后的任何内容。

但是在纵向版本上,它可以在 Eclipse 中正确渲染,但不能在我的设备上正确渲染(Samsung Galaxy Tab 2 10.1)。如果相关,我专门针对此屏幕和设备。

有人有什么主意吗?

<?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:baselineAligned="true"
    android:orientation="vertical" >

    <!-- the id itemListItemList is named that way on purpose -->
    <!-- This will be filled programmatically as items are added to the inventory -->

    <ScrollView
        android:id="@+id/itemListScrollView"
        android:fillViewport="true"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:scrollbarStyle="insideOverlay" >

        <LinearLayout
            android:id="@+id/itemListItemList"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:orientation="vertical" >

        </LinearLayout>

    </ScrollView>

    <RelativeLayout
        android:id="@+id/itemListRelLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" >

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp" >

            <EditText
                android:id="@+id/itemListItemName"
                style="@style/item_list_label_style"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/label_background"
                android:clickable="false"
                android:cursorVisible="false"
                android:ems="10"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:hint="@string/item_list_item_label"
                android:inputType="none"
                android:paddingLeft="11dp"
                android:singleLine="true" />

            <EditText
                android:id="@+id/itemListItemTag"
                style="@style/item_list_label_style"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@drawable/label_background"
                android:clickable="false"
                android:cursorVisible="false"
                android:ems="10"
                android:focusable="false"
                android:focusableInTouchMode="false"
                android:hint="@string/item_list_tag_label"
                android:inputType="none"
                android:paddingLeft="11dp"
                android:singleLine="true" />
        </LinearLayout>

        <EditText
            android:id="@+id/itemListItemDescSym"
            style="@style/item_list_label_style"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/linearLayout1"
            android:layout_marginTop="23dp"
            android:background="@drawable/label_background"
            android:clickable="false"
            android:cursorVisible="false"
            android:ems="10"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:hint="@string/item_list_desc_sym_label"
            android:inputType="none"
            android:paddingLeft="11dp"
            android:singleLine="true" />

        <EditText
            android:id="@+id/itemListItemExceptions"
            style="@style/item_list_label_style"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_below="@+id/itemListItemDescSym"
            android:layout_marginTop="26dp"
            android:background="@drawable/label_background"
            android:clickable="false"
            android:cursorVisible="false"
            android:ems="10"
            android:focusable="false"
            android:focusableInTouchMode="false"
            android:hint="@string/item_list_exceptions_label"
            android:inputType="none"
            android:paddingLeft="11dp"
            android:singleLine="true" />

        <!--
             <Button
            android:id="@+id/item_list_void_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBaseline="@+id/item_list_clear_button"
            android:layout_alignBottom="@+id/item_list_clear_button"
            android:layout_alignParentRight="true"
            android:layout_marginRight="27dp"
            android:text="@string/item_list_void_button" />
        -->

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true" >

            <Button
                android:id="@+id/item_list_edit_button"
                android:layout_width="wrap_content"
                android:layout_height="75dp"
                android:layout_gravity="left"
                android:layout_weight="1"
                android:text="@string/item_list_edit_button" />

            <Button
                android:id="@+id/item_list_clear_button"
                android:layout_width="wrap_content"
                android:layout_height="75dp"
                android:layout_gravity="center_horizontal"
                android:layout_weight="1"
                android:text="@string/item_list_clear_button" />

            <Button
                android:id="@+id/item_list_void_button"
                android:layout_width="wrap_content"
                android:layout_height="75dp"
                android:layout_gravity="right"
                android:layout_weight="1"
                android:text="@string/item_list_void_button" />
        </LinearLayout>
    </RelativeLayout>

</LinearLayout>
4

1 回答 1

0

在滚动视图标签处设置 android:fillViewport="true"

于 2017-02-07T09:02:03.640 回答