【发布时间】:2014-01-01 13:49:23
【问题描述】:
我使用 XML 进行布局,但我需要以编程方式定位 ImageButton。谁能告诉我怎么做?
XML
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainScreenLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:id="@+id/mainScreenImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="@drawable/screenimage"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/titleview"
android:background="#00000000"
android:adjustViewBounds="true"
android:src="@drawable/buttonstart"/>
</FrameLayout>
【问题讨论】:
-
到目前为止你尝试了什么?
-
@Nizam 我尝试了 1)Rudra 在下面通过将 AbsoluteLayout 更改为 FrameLayout 但无法编译,2)尝试了 setBoundsInScreen(Rect) 但我不知道如何正确使用它所以无法编译跨度>
标签: android xml layout imagebutton