<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/layout_blue_border"
android:weightSum="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="5"
android:layout_weight="1.5"
android:layout_margin="@dimen/abc_button_inset_horizontal_material"
android:outlineProvider="none">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/textView2"
android:layout_marginLeft="@dimen/abc_control_inset_material">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Moisture Probe Info"
android:id="@+id/textView9"
android:layout_weight="1"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:textSize="@dimen/abc_text_size_button_material"
android:textStyle="bold" />
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:outlineProvider="none"
android:orientation="horizontal"
android:layout_below="@+id/ActvCal"
android:layout_alignLeft="@+id/display_tv"
android:layout_alignStart="@+id/display_tv"
android:weightSum="5"
android:layout_weight="0" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_weight="1"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Serial #:"
android:id="@+id/Serial"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/serial_val"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Battery:"
android:id="@+id/Battery"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Battery_val"
android:layout_column="8"
android:text="0"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:layout_alignParentRight="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Firmware Ver:"
android:id="@+id/Firmware"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Firmware_val"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Date:"
android:id="@+id/date"
android:textIsSelectable="false"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/date_val"
android:layout_column="8"
android:layout_alignParentEnd="true"
android:layout_weight="1"
android:layout_alignParentRight="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="2"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MAC Addr:"
android:id="@+id/MACaddr"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mac_val"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Latitude"
android:id="@+id/Long_text"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Latitude_val"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Longitude"
android:id="@+id/textView3"
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Longitude_val"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/activity_horizontal_margin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Note"
android:layout_column="8"
android:layout_weight="1" />
</LinearLayout>
</TableLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="3"
android:layout_gravity="bottom"
android:gravity="bottom|fill_vertical"
android:layout_weight=".5"
android:layout_marginLeft="@dimen/activity_horizontal_margin">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/button2"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/Return2"
android:layout_toStartOf="@+id/Return2"
android:layout_alignTop="@+id/button1"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:outlineProvider="none" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text=""
android:id="@+id/button1"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:layout_weight="1"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:outlineProvider="none" />
<Button
android:id="@+id/Return2"
android:text="Return to Main Menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/button2"
android:background="@drawable/button_shape_grey"
android:layout_weight="1"
android:textSize="@dimen/abc_text_size_caption_material"
android:layout_marginRight="@dimen/activity_horizontal_margin"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:indeterminate="false"
android:layout_weight=".1"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_gravity="top|center_horizontal" />
</RelativeLayout>
我是Android编程新手。布局在某些设备上正确显示,而在其他设备上则被切断。我添加了像&#34; @ dimen / activity_horizontal_margin&#34;在XML中进行布局。我希望这些可以根据屏幕尺寸计算,但事实并非如此。我怎样才能提到根据可用空间计算的保证金?
答案 0 :(得分:0)
首先,你有这么多包裹的布局并不好。 第二,在这些情况下使用重量非常糟糕,因为Android需要大量时间来计算最深部分内的值。
通过这种方式,你需要更好地使用 TableLayout 来达到同样的目的。