Android 如何在ImageView顶部创建按钮并将其与屏幕底部对齐?
我想使用我的Android 如何在ImageView顶部创建按钮并将其与屏幕底部对齐?,android,xml,button,imageview,android-linearlayout,Android,Xml,Button,Imageview,Android Linearlayout,我想使用我的xml文件在ImageView顶部设置一个按钮。当我运行此代码时,该按钮出现在屏幕左侧其他按钮的顶部 是否有人知道如何在ImageView顶部但在屏幕底部设置一个按钮 到目前为止,我有以下几点: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" ...... <Imag
xml
文件在ImageView
顶部设置一个按钮。当我运行此代码时,该按钮出现在屏幕左侧其他按钮的顶部
是否有人知道如何在ImageView
顶部但在屏幕底部设置一个按钮
到目前为止,我有以下几点:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
......
<ImageView
android:id="@+id/filter_image_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/filter_linear_layout" />
//this is the button I want to have on top of the ImageView
<Button
android:id="@+id/display_RGB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/button_blue_red_transluscent"
android:text="@string/display_RGB"
android:textColor="@android:color/white" />
</RelativeLayout>
您可以将它们放在自己的RelativeLayout中,然后可以非常轻松地操纵按钮相对于ImageView的位置
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/filter_linear_layout" >
<ImageView
android:id="@+id/filter_image_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/display_RGB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_blue_red_transluscent"
android:text="@string/display_RGB"
android:textColor="@android:color/white"
android:layout_centerHorizontal="true"
android:layout_below="@id/filter_image_view"
/>
</RelativeLayout>
您可能希望通过将以下内容添加到按钮,在ImageView和Button之间添加一些间距:
android:layout_marginTop="8dp"
您可以将它们放在自己的RelativeLayout中,然后可以非常轻松地操纵按钮相对于ImageView的位置
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_toRightOf="@id/filter_linear_layout" >
<ImageView
android:id="@+id/filter_image_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/display_RGB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_blue_red_transluscent"
android:text="@string/display_RGB"
android:textColor="@android:color/white"
android:layout_centerHorizontal="true"
android:layout_below="@id/filter_image_view"
/>
</RelativeLayout>
您可能希望通过将以下内容添加到按钮,在ImageView和Button之间添加一些间距:
android:layout_marginTop="8dp"
试试这个
<Button
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="16dip"
android:text="hi"
android:textColor="@color/black"
/>
试试这个
<Button
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="16dip"
android:text="hi"
android:textColor="@color/black"
/>
Try with ImageButton Try with ImageButton+1-这就是东西,只需要放一张图片,告诉你我指的imageview上的位置。请稍等,走吧。图像向上+1-这是东西,只需要放一张图片,告诉你在imageview上的位置,我的意思是。请稍等,走吧。图像是向上的