Xml适用于平板电脑,但不适用于小于7英寸的设备

时间:2017-12-28 10:38:54

标签: android android-layout listview layout

下面的我的xml是关于在水平滚动视图中有一个列表视图。它在平板电脑上运行良好,我测试了联想Tab7必备和三星星系10英寸。但是当涉及到小于7英寸的设备时,它的投掷错误。帮助我

android.view.InflateException:二进制XML文件行#0:二进制XML文件行#0:您必须提供layout_height属性。

<?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"
android:verticalScrollbarPosition="right">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/headerheight"
    android:background="#dc5E4485"
    android:orientation="horizontal"
    android:weightSum="1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight=".1"
        android:gravity="center_vertical|left"
        android:paddingLeft="3sp"
        android:text="@string/app_name"
        android:textColor="@color/white"
        android:textSize="25sp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/next_tableView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="3sp"
        android:layout_marginRight="6sp"
        android:layout_marginTop="3sp"
        android:layout_weight=".9"
        android:src="@drawable/next"
        android:text="Next" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/linearlayout"
        android:layout_width="@dimen/column_width_min"
        android:layout_height="match_parent"
        android:background="@color/white"
        android:orientation="vertical"
        android:weightSum="1">

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight=".30"
            android:background="@drawable/thin_line_border"
            android:gravity="center"
            android:singleLine="true"
            android:text="Select"
            android:textSize="@dimen/textsize" />

        <TextView
            android:layout_width="@dimen/column_width_min"
            android:layout_height="match_parent"
            android:layout_weight=".31"
            android:gravity="center"
            android:singleLine="true"
            android:text="S.No"
            android:textSize="@dimen/textsize"
            android:textStyle="bold" />

        <ListView
            android:id="@+id/inventoryItemList1"
            android:layout_width="210dp"
            android:layout_height="match_parent"
            android:layout_weight=".09"
            android:background="@drawable/thin_line_border"
            android:divider="@null">

        </ListView>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight=".30"
            android:background="@color/white"
            android:gravity="bottom">

            <Button
                android:id="@+id/save_tableView"
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:background="@drawable/thick_line_border"
                android:gravity="center"
                android:text="Save" />
        </LinearLayout>


    </LinearLayout>

    <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_toEndOf="@+id/linearlayout"
        android:scrollbarAlwaysDrawVerticalTrack="false">

        <RelativeLayout
            android:id="@+id/relativeLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

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

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight=".30"
                    android:background="@color/white"
                    android:orientation="horizontal">

                    <LinearLayout
                        android:layout_width="@dimen/column_width_twice"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:weightSum="2">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:singleLine="true"
                            android:text="Accessories short supply"
                            android:textSize="@dimen/textsize"
                            android:textStyle="bold" />

                        <Spinner
                            android:prompt="@string/spinner_title"
                            android:id="@+id/spinner1"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:textSize="@dimen/textsize" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="@dimen/column_width_twice"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:weightSum="2">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:singleLine="true"
                            android:text="Improper Lugging"
                            android:textSize="@dimen/textsize"
                            android:textStyle="bold" />

                        <Spinner
                            android:prompt="@string/spinner_title"
                            android:id="@+id/spinner2"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:textSize="@dimen/textsize" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="@dimen/column_width_twice"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:weightSum="2">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:text="Cell Bypass(or)Reverse polarity"
                            android:textSize="@dimen/textsize"
                            android:textStyle="bold" />

                        <Spinner
                            android:prompt="@string/spinner_title"
                            android:id="@+id/spinner3"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:textSize="@dimen/textsize" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="@dimen/column_width_twice"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:weightSum="2">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:singleLine="true"
                            android:text="Add Leakage/ Over Charge"
                            android:textSize="@dimen/textsize"
                            android:textStyle="bold" />

                        <Spinner
                            android:prompt="@string/spinner_title"
                            android:id="@+id/spinner4"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:textSize="@dimen/textsize" />

                    </LinearLayout>

                    <LinearLayout
                        android:layout_width="@dimen/column_width_twice"
                        android:layout_height="match_parent"
                        android:orientation="vertical"
                        android:weightSum="2">

                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:singleLine="true"
                            android:text="Improper Connection &amp;mixing of Other make capacity cells"
                            android:textSize="@dimen/textsize"
                            android:textStyle="bold" />

                        <Spinner
                            android:prompt="@string/spinner_title"
                            android:id="@+id/spinner5"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:gravity="center"
                            android:textSize="@dimen/textsize" />

                    </LinearLayout>

                </LinearLayout>

                <LinearLayout
                    android:id="@+id/assetTitleLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:layout_weight=".31"
                    android:background="#3a5E4485"
                    android:orientation="horizontal">

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="@dimen/column_width"
                        android:layout_height="match_parent"
                        android:background="@drawable/background_button_ghost"
                        android:gravity="center"
                        android:singleLine="true"
                        android:text="Cell SL.Nos"
                        android:textSize="@dimen/textsize"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textView2"
                        android:layout_width="@dimen/column_width"
                        android:layout_height="match_parent"
                        android:background="@drawable/background_button_ghost"
                        android:gravity="center"
                        android:singleLine="true"
                        android:text="MFG DT"
                        android:textSize="@dimen/textsize"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textView3"
                        android:layout_width="@dimen/column_width"
                        android:layout_height="match_parent"
                        android:background="@drawable/background_button_ghost"
                        android:gravity="center"
                        android:singleLine="true"
                        android:text="OCV(or)ON Charge(v)"
                        android:textSize="@dimen/textsize"
                        android:textStyle="bold" />


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

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="horizontal">

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="Discharge Reading"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:orientation="horizontal">

                            <TextView
                                android:id="@+id/textView4"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="15 min"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/textView5"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="30 min"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/textView6"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="1.00 Hr"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/textView7"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="1.30 Hr"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/textView8"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="2.00 Hrs"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />
                        </LinearLayout>

                    </LinearLayout>

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

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1"
                            android:background="@drawable/background_button_ghost"
                            android:orientation="horizontal">

                            <TextView
                                android:layout_width="match_parent"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="Charge Reading"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />
                        </LinearLayout>

                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_weight="1">

                            <TextView
                                android:id="@+id/textView9"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="30 Min"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />

                            <TextView
                                android:id="@+id/textView10"
                                android:layout_width="@dimen/column_width"
                                android:layout_height="match_parent"
                                android:background="@drawable/background_button_ghost"
                                android:gravity="center"
                                android:singleLine="true"
                                android:text="1.00 Hr"
                                android:textSize="@dimen/textsize"
                                android:textStyle="bold" />
                        </LinearLayout>
                    </LinearLayout>
                </LinearLayout>

                <ListView
                    android:id="@+id/inventoryItemList"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight=".09"
                    android:divider="@null"></ListView>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_weight=".30"
                    android:background="@color/white"
                    android:orientation="vertical"
                    android:weightSum="1">

                    <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_weight=".5">

                        <TextView
                            android:layout_width="@dimen/column_width_twice"
                            android:layout_height="match_parent"
                            android:gravity="center"
                            android:paddingLeft="2dp"
                            android:text="Total Voltage:(V)"
                            android:textColor="@color/black"
                            android:textSize="@dimen/textsize" />

                        <TextView
                            android:id="@+id/et_Vtotal1"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal2"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal3"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal4"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal5"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal6"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal7"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                        <TextView
                            android:id="@+id/et_Vtotal8"
                            android:layout_width="@dimen/column_width"
                            android:layout_height="match_parent"
                            android:background="@drawable/background_button_ghost"
                            android:text="" />

                    </LinearLayout>

                </LinearLayout>

            </LinearLayout>
        </RelativeLayout>
    </HorizontalScrollView>

</LinearLayout>

1 个答案:

答案 0 :(得分:0)

检查并查看您是否在此处使用了所有尺寸的标题高度

android:layout_height="@dimen/headerheight"

为每个维度定义,请参阅此

https://stackoverflow.com/a/32861248/5608448