【发布时间】:2018-07-21 06:24:18
【问题描述】:
我正在尝试使用 3 个项目在 RelativeLayout 中制作页脚 - 一个 ImageView、一个 TextView 和一个 Button。我设法将ImageView 定位在布局的左侧,将TextView 定位在左侧的ImageView 附近。但是,我无法在布局右侧正确设置按钮的位置。编辑器和我的设备中的位置不同(当我测试它时)。当我在编辑器中以我想要的方式放置所有内容时,在设备上运行它后它看起来不一样。应该在布局右侧的Button 离开屏幕。
例如this 是我在编辑器中看到的,this 是我在设备上看到的。如果我在编辑器中将按钮移动到它应该在的位置like this,然后它会在设备上离开屏幕like this。
我也尝试使用LinearLayout、gravity、layout_gravity、weight 以及填充和边距的不同组合,但我就是无法让它工作,我不明白问题出在哪里。
这是我的 xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:padding="4dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background" />
<ImageView
android:layout_width="55dp"
android:layout_height="55dp"
android:paddingBottom="3dp"
android:paddingTop="3dp"
android:src="@mipmap/help" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="60dp"
android:paddingTop="10dp"
android:text="help"
android:textColor="@color/mainWhite" />
<Button
android:id="@+id/helpButton"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_marginLeft="330dp"
android:layout_marginTop="3dp"
android:background="@mipmap/Continue" />
</RelativeLayout>
谢谢。
【问题讨论】:
标签: android android-layout android-button android-relativelayout