2010-09-24 117 views

回答

11

設置爲背景!

只是開個玩笑......你需要的是把你的意見RelativeLayout內。喜歡的東西將工作:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"/> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentBottom="true" 
     android:text="blah blah"/> 
</RelativeLayout> 

注意使用PARAMS像layout_alignParentLeft這是用來定位在要視圖。

+2

您也可以使用合併(http://developer.android.com/resources/articles/layout- tricks-merge.html)或一個framelayout(http://developer.android.com/resources/articles/layout-tricks-merge.html) – William 2010-09-24 23:23:37

+2

上面的鏈接現在已經死了,試試這個:http:// developer。 android.com/training/improving-layouts/reusing-layouts.html – 2013-01-22 05:20:56

0

我同意@ Cristian的回答。而且, 如果您需要按鈕的動作偵聽器,則可以在不使用按鈕的情況下將onClick方法添加到imageView。

還ImageButton。我希望這個答案能夠解決你的問題。

0

爲我工作既ImageViewButtonRelativeLayout

<Button android:layout_centerInParent="true"> 

...