android - XML 布局与模拟器不同
问题描述
我已经花了 4 个小时来解决这个问题,但我无法解决它请任何帮助将不胜感激。当我更新我的 android 工作室时,这个问题停留在我的 android 工作室中。我正在使用 android studio 最新版本 3.2.1。
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:layout_height="match_parent"
tools:context=".View.First_Screen">
<ImageView
android:id="@+id/firstScreen_image"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="@drawable/snap"
android:src="@drawable/black_transparent" />
<LinearLayout
android:id="@+id/firstScreen_buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/firstScreen_image"
android:layout_marginTop="38dp"
android:orientation="horizontal"
android:weightSum="1">
<Button
android:id="@+id/firstScreen_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="2dp"
android:layout_weight="0.5"
android:background="@drawable/button_background"
android:text="Login" />
<Button
android:id="@+id/firstScreen_register"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="5dp"
android:layout_weight="0.5"
android:background="@drawable/button_background"
android:text="register" />
</LinearLayout>
<TextView
android:id="@+id/firstScreen_connectDriver"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/firstScreen_buttonLayout"
android:layout_marginLeft="5dp"
android:layout_marginTop="32dp"
android:text="Or be a captain of uber"
android:textColor="#311B92"
android:textSize="18dp"
android:textStyle="bold" />
</RelativeLayout>
解决方案
首先,我想确认您使用的是哪个模拟器,它是 nexus 4 还是其他模拟器,因为在预览中您的屏幕被选择为 nexus 4,并且视图显示的设备具有与 nexus 4 相同的像素密度和分辨率,接下来,您使用 id -“firstScreen_image”为 ImageView 提供了一个固定的 dp 高度。对于不同的设备,固定高度(即 350dp)的行为会有所不同。那么下一个问题是你希望你的屏幕是什么样的,我能提供什么帮助?
推荐阅读
- html - MS Word HTML - 是否可以为一个元素分配多个类?
- sql - 对可能为空的多列强制唯一性
- vb.net - 组织资源文件
- performance - 为什么 Svelte 组件的增量成本高于 VDOM 框架?
- oracle - Oracle 的 SSIS 错误-反序列化包“值不在预期范围内”的异常
- python - 我不知道如何正确使用 fetch_message,discord.py
- javascript - 带有javascript的过渡不透明度不起作用
- java - SpringGuice 注入未命中
- python - Python中的因子多项式方程?
- java - java - 如何在java中创建一个联系表单删除按钮来删除选定的元素?