【发布时间】:2021-02-10 20:24:47
【问题描述】:
为什么按钮不稳定
从下图可以看出,为什么其他手机的按钮在不同的地方
你能帮我解决这个问题吗
我希望每部手机上的按钮都位于同一个位置。 (和第一张图一样)
我的手机
我朋友的电话(huwai)
我朋友的手机(三星)
我使用的代码如下。如何更改这些代码才能解决此问题?我对编码不太了解
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/v"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/y"
android:text="Değiştir"
android:textColor="#ffffff"
android:layout_marginStart="20dp"
android:layout_marginBottom="60dp"
android:textSize="15dp"
android:onClick="random"/>
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@drawable/y"
android:layout_marginBottom="60dp"
android:layout_marginEnd="20dp"
android:text="Kopyala"
android:textColor="#ffffff"
android:onClick="kopyala"
android:textSize="15dp" />
<Button
android:text="Paylaş"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:background="@drawable/y"
android:layout_marginBottom="60dp"
android:layout_marginEnd="140dp"
android:textColor="#ffffff"
android:textSize="15dp"
android:id="@+id/button"
android:onClick="paylas"/>
</RelativeLayout>
【问题讨论】:
-
使用约束布局而不是相对布局
标签: java android android-relativelayout