我需要創建如下:如何將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。 –