java - 如何将 Android 按钮放置在 TextView 之上?

标签 java android

我需要创建以下内容:

----------------------------------------------------
|     |                                            |
|     |                                            |
----------------------------------------------------
   |                       |
   ImageButton             TextView

ImageButton 有一个图像,需要缩放以适应 TextView 的高度...

我成功地使用RelativeLayout 来定位按钮:

       <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:id="@+id/tense_textview"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/tense"
                android:gravity="center_horizontal"
                android:background="@android:color/holo_orange_dark"
                android:padding="15dp"
                android:textStyle="bold"
                android:textColor="@android:color/white" />
            <ImageButton
                android:id="@+id/pauseButton"
                android:background="@drawable/pause_button_background"
                android:src="@drawable/pause"
                android:layout_alignParentTop="true"
                android:layout_alignParentLeft="true"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="10dp" />
        </RelativeLayout>

但是,这给了我:

                           TextView
                           |
----------------------------------------------------  
|         |                                        |
|         |                                        |
|         |-----------------------------------------
|         |                                        |
----------------------------------------------------
     |                     |
     ImageButton           RelativeLayout

有什么想法吗?

最佳答案

您需要添加属性:

android:layout_alignBottom="@+id/tense_textview"

android:layout_alignTop="@+id/tense_textview" 到你的 ImageView

关于java - 如何将 Android 按钮放置在 TextView 之上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33243810/

相关文章:

java - 在 myeclipse 中安装 windowBuilder

java - request.getRemoteAddr() 返回服务器ip

jquery - 样式化 JQuery 移动主题

java - 如何在列中显示饼图的图例?

java - 什么时候在 Eclipse 中创建多个项目?

java - 是否可以抛出 java.lang.Error?

android - 如何使用 Retrofit 1.9 从下面的响应中获取图像?

Android - keystore 、应用内购买和外包开发

android - Google Play 服务 7.0 设置对话框

android - 使用 glide 添加进度条