android - 应用程序设计在图形中与模拟器中的实际位置

标签 android

我在android平台上非常新手。我正在尝试设计一个应用程序。出于设计目的,我采用了RelativeLayout。但是我注意到的独特之处是在图形布局中看到它时在eclipse中,Buttons和EditText的位置不同,而在模拟器中看到的位置是正确的。

这是我的代码..

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/pnr_bg"
android:orientation="vertical"
android:padding="0dp" >

<ImageButton
    android:id="@+id/ImageButton01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="100dp"
    android:layout_marginTop="220dp"
    android:maxHeight="30dp"
    android:src="@drawable/pnr_normal" />


<ImageButton
    android:id="@+id/ImageButton01"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="266dp"
    android:layout_marginTop="220dp"
    android:maxHeight="30dp"
    android:src="@drawable/tenq_normal" />

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:ems="10" >

    <requestFocus />
</EditText>

<ImageButton
    android:id="@+id/imageButton1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="50dp"
    android:src="@drawable/submit" />

<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_column="0"
android:layout_columnSpan="6"
android:layout_gravity="right|bottom"
android:layout_row="6"
android:layout_height="match_parent"
android:textColor="#0f0f0f" />

为什么会出现这种情况。对不同尺寸的手机屏幕有什么影响吗? 请帮助我..

最佳答案

是的,这是正确的事情。无论您看到什么布局/UI,它在模拟器或真实设备中都不会相同。原因是 Android 具有多种分辨率。您在设计时看到的布局只是预览设计,或者我们可以说只是您使用的控件/小部件的 UI 示例预览。

您可以将其视为在 android 中针对不同分辨率/多个屏幕设计 UI/布局的优势。

当我说优势时,这意味着您可以只设计一个布局并可以在多个屏幕上预览它,因此您会有更好的想法。

更新:

只需检查图像并执行与图像中所示相同的操作即可预览所有屏幕。我再次重复一遍,您看到的预览只是预览,在真实设备中看起来会有所不同。

enter image description here

关于android - 应用程序设计在图形中与模拟器中的实际位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23485980/

相关文章:

android - 屏幕关闭时 DialogFragment IllegalStateException

android - 如何将 android Textview 元素居中放置在屏幕底部

android - 在 Android @drawable 中查找图像的主色

android - 单击按钮时滚动 ListView

java - 单击按钮后如何将Paypal集成到付款用户?

android - 调试在服务类中不起作用 ??什么会导致这个问题?

android - 失败 : Build failed with exception

android - 上标影响行高

java - 如何改变TextView的文字

android - java.lang.IllegalStateException ConstraintLayout 没有为 fragment 设置 NavController