【发布时间】:2018-02-11 16:20:40
【问题描述】:
当我用 android 模拟器预览时,布局预览没问题。但是当我在手机中安装应用程序时,视图会重叠。可能是因为手机屏幕空间不足,但我不知道。请帮帮我。并且还帮助我使这个应用程序适用于所有屏幕尺寸。提前致谢。
第一张图片是模拟器预览,第二张是手机预览
这里是xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:orientation="vertical"
android:background="@drawable/newbackground"
tools:context=".MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="300dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
app:srcCompat="@drawable/dicee_logo" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/dicee_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/dice1" />
<ImageView
android:id="@+id/dicee_left"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="@drawable/dice2" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/roll_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="61dp"
android:background="@color/colorPrimary"
android:text="@string/button_text"
android:textColor="@android:color/white" />
<Button
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/roll_button"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/roll_button"
android:layout_marginBottom="25dp"
android:background="@android:color/holo_blue_light"
android:text="Next page" />
</RelativeLayout>
</LinearLayout>
【问题讨论】:
标签: java android xml android-layout