我需要创建以下内容:
----------------------------------------------------
| | |
| | |
----------------------------------------------------
| |
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/