更改屏幕大小后,按钮的大小和位置也会更改XAMARIN.ANDROID

时间:2018-10-12 20:42:36

标签: c# android xamarin button xamarin.android

我正在尝试在我的android活动中放置一个按钮。我正在使用xamarin.android和(不是xamarin.forms)创建它,但似乎无法将按钮放置在我喜欢的位置。

我的按钮代码看起来像这样,可以将按钮放在想要的位置。

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal">
<AbsoluteLayout
    android:minWidth="25px"
    android:minHeight="25px"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/frameLayout1">
    <ImageView
        android:id="@+id/myImage"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:src="@drawable/my_image" />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/gotologin"
        android:layout_x="125px"
        android:layout_y="482px"  />
</AbsoluteLayout>

</RelativeLayout>

但是,当我将屏幕尺寸更改为另一个模拟器时,位置也会改变。我显然做错了,但是我似乎找不到一种方法来使所有屏幕尺寸的按钮的尺寸和位置保持不变。

请,有人可以指出我需要阅读的文档部分的正确方向吗? 谢谢。

屏幕截图

Screen size one

screen size two

请注意按钮位置已更改。

0 个答案:

没有答案