在Android中显示图像上方的按钮

时间:2014-10-03 09:38:35

标签: java android android-layout android-activity imageview

我正在创建一个Android应用程序,其中我有一个ImageView和一个Forward Arrow Button,我想要的是在图像上方的屏幕右中心显示按钮。 这是我的代码.....

<ImageView
    android:id="@+id/ImageShow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" /> 

 <EditText
android:id="@+id/postal_address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/postal_address_hint"
android:inputType="textPostalAddress" />

2 个答案:

答案 0 :(得分:0)

也许你可以尝试这样的事情:

<RelativeLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">

     <ImageView
        android:id="@+id/ImageShow"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" /> 

    <Button
        android:id="@+id/YOUR_BUTTON_ID"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/ImageShow" /> 

</RelativeLayout>

答案 1 :(得分:0)

<RelativeLayout
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical">

     <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" /> 

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_alignParentRight="true"
         /> 

</RelativeLayout>