我试着做Android的手电筒应用程序(作为一个绝对的初学者)按钮置于相对保持背景图像
的概念是让钢铁侠的胸部光作为闪光UI切换按钮。
我设置铁人作为背景ImageView。并将胸部照片设置为按钮的图像src。
问题是,在不同的屏幕尺寸下,按钮的对齐方式会发生变化,您可以在下面的屏幕截图中看到。 这就是它的样子:
按钮时,屏幕尺寸改为流离失所:
如果有人可以帮助我,我怎么能解决这个问题,它会很棒。
我的XML代码,如果这将是有帮助:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
tools:context="example.flash.flash">
<!-- view for AdMob Interstitial Ad -->
<TextView
android:id="@+id/app_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="@string/interstitial_ad_sample"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/app_title"
android:layout_centerHorizontal="true"
android:text="@string/start_level"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/next_level_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/next_level" />
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/iron"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/colorBackground"
android:src="@drawable/onn"
android:scaleType="fitCenter"
android:layout_marginBottom="57dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_home_footer"></com.google.android.gms.ads.AdView>
</RelativeLayout>