我需要创建如下:如何将Android按钮放置在TextView之上?
----------------------------------------------------
| | |
| | |
----------------------------------------------------
| |
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
有什么想法?
简单,不要使用ImageView的。在TextView中使用**复合可绘制**。顺便说一句,你也可以通过这样做来摆脱无用的RelativeLayout。因此,在你的TextView中写入:'android:drawableLeft =“@ drawable/pause”' –
虽然这不会影响图像的缩放... – lombrozo
如果设置了TextView高度,将缩放到适合ImageView的高度wrap_content。 –