【发布时间】:2017-12-28 10:38:54
【问题描述】:
我下面的 xml 是关于在水平滚动视图内有一个列表视图。它在我测试过联想 Tab7 Essential 和三星 Galaxy 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 &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>
【问题讨论】:
-
尝试检查您的
dimens.xml移动文件。也许一个值是 100 而不是 100dp 或类似的东西。 -
我已经验证了它们在 dp 中被正确分配它在平板电脑中工作
-
尝试将移动设备的
dimens.xml替换为平板电脑的dimens.xml。如果没有错误,则意味着dimens.xmlfor mobile 中的某处有错误的语法。
标签: android android-layout listview layout