按钮向下对齐,已从图像视图中隐藏

问题描述 投票:-1回答:2

我想在版式底部放置一个按钮。我也用layout_alignParentTop放置了一个图像视图,我的问题是我的图像视图隐藏了我的按钮。我该如何解决?

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
 android:layout_width="match_parent" 
 android:layout_height="match_parent">

  <Button android:id="@+id/btnGetMoreResults"
   android:layout_height="wrap_content" 
   android:layout_width="match_parent"     
   android:text="Get more"
   android:layout_alignParentBottom="true" />

    <ImageView
        android:layout_alignParentTop="true" 
        android:src="@android:drawable/ic_menu_gallery"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/btnGetMoreResults"
        android:id="@+id/imageView1" />

</RelativeLayout> 

看下面的图片

img

我应该使用CoordinatorLayout代替RelativeLayout吗?

java android xml xamarin
2个回答
0
投票

在您的ImageView中,不要使用

android:layout_alignParentBottom="true"

您必须使用

android:layout_above="@+id/your_button"

这是最终代码,请不要忘记根据需要对其进行修改

<RelativeLayout
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:layout_alignParentTop="true"
        android:layout_above="@id/button"
        android:layout_width="match_parent"
        android:layout_height="0dp"/>
    <Button
        android:id="@+id/button"
        android:layout_alignParentBottom="true"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</RelativeLayout>

0
投票

在imageview中使用它

android:margin_bottom="50dp";
© www.soinside.com 2019 - 2024. All rights reserved.