Android layout 为什么我的android应用程序在我的设备上运行良好,但在其他设备上运行不好,因为我的组件放错了地方?
我已经创建了我的第一个android应用程序 它在我的设备上运行良好,所有组件都在正确的位置和相同的大小,但当我在另一部手机上运行时,所有组件都放错了位置 有什么问题吗?特别是ImageViewAndroid layout 为什么我的android应用程序在我的设备上运行良好,但在其他设备上运行不好,因为我的组件放错了地方?,android-layout,Android Layout,我已经创建了我的第一个android应用程序 它在我的设备上运行良好,所有组件都在正确的位置和相同的大小,但当我在另一部手机上运行时,所有组件都放错了位置 有什么问题吗?特别是ImageView <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/imageView" android:src="@drawabl
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:src="@drawable/backg"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:layout_width="320dp"
android:layout_height="400dp"
android:id="@+id/chart"
android:layout_above="@+id/button2"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="160dp"
android:layout_height="wrap_content"
android:text="Next"
android:id="@+id/button2"
android:onClick="clickedOnPlay2"
android:background="#4cb076"
android:layout_marginBottom="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
请帮忙
谢谢。试试这个布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/backg"
android:fitsSystemWindows="true"
tools:context="com.example.user25.myapplication.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|center_vertical">
<ImageView
android:layout_width="320dp"
android:layout_height="400dp"
android:id="@+id/chart"
android:layout_marginTop="40dp"
android:layout_gravity="center_horizontal"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true">
<Button
android:layout_width="160dp"
android:layout_height="wrap_content"
android:text="Next"
android:id="@+id/button2"
android:onClick="clickedOnPlay2"
android:background="#4cb076"
android:layout_marginTop="10dp"
android:layout_marginBottom="60dp"
/>
</LinearLayout>
</RelativeLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</LinearLayout>
不工作,兄弟,同样的问题…我必须创建不同的布局目录,比如小布局、大布局???你检查过我的截图吗??