【发布时间】:2016-04-02 08:36:00
【问题描述】:
我正在开发我的第一个 android 应用程序并使用 xamarin。其他一切正常,但是当我在不同设备之间切换时,由于分辨率的变化,我的 UI 元素的位置和大小会发生变化。下面是我正在使用的 Main.xml 代码。
<?xml version="1.0" encoding="utf-8"?>
<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/avsar_ui"
android:weightSum="100"
android:minWidth="200px"
android:minHeight="200px"
android:id="@+id/linearLayout1">
<EditText
android:text="name"
android:textColor="?android:attr/searchWidgetCorpusItemBackground"
android:inputType="textPersonName"
android:layout_marginTop="225.0dp"
android:layout_marginBottom="25.0dp"
android:layout_width="match_parent"
android:background="@drawable/rounded_corner"
android:layout_marginLeft="50.0dp"
android:layout_marginRight="50.0dp"
android:layout_height="wrap_content"
android:id="@+id/PersonName" />
<EditText
android:text="Contact Number"
android:textColor="?android:attr/searchWidgetCorpusItemBackground"
android:inputType="numberSigned"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/rounded_corner"
android:layout_marginLeft="50.0dp"
android:layout_marginBottom="10.0dp"
android:layout_marginRight="50.0dp"
android:id="@+id/ContactNumber" />
<EditText
android:text="Address"
android:textColor="?android:attr/searchWidgetCorpusItemBackground"
android:inputType="textPostalAddress"
android:layout_width="match_parent"
android:background="@drawable/rounded_corner"
android:layout_marginLeft="50.0dp"
android:layout_marginRight="50.0dp"
android:layout_marginBottom="10.0dp"
android:layout_height="wrap_content"
android:id="@+id/Address" />
<Spinner
android:layout_width="125.0dp"
android:background="@drawable/dropbox_bg"
android:layout_marginLeft="50.0dp"
android:layout_height="40.0dp"
android:id="@+id/Quantity" />
<Button
android:background="@drawable/order_button"
android:layout_marginBottom="60dp"
android:layout_marginTop="100dp"
android:layout_marginLeft="115.0dp"
android:layout_marginRight="115.0dp"
android:layout_width="150.0dp"
android:layout_height="50.0dp"
android:id="@+id/OrderButton" />
</LinearLayout>
【问题讨论】:
标签: android xml user-interface resolution