2015-09-25 81 views
-1

我需要使用按鈕作爲佈局右下角的出口和佈局中心下方的圖像按鈕來調整佈局。它應該準確地支持多個屏幕的背景。 我使用了相對佈局,裏面有圖像按鈕,但我無法將圖像按鈕2設置在其位置上。如果我這樣做,整個佈局是垂直擴展。相對佈局兒童位置

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#00ffffff" 
android:orientation="vertical" 
tools:context="com.rabiya.menu.MainActivity" 
android:id="@+id/rl01" > 




<RelativeLayout 
    android:id="@+id/rl02" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginBottom="15dp" 
    android:background="@drawable/background3" > 
    <ImageButton 
     android:id="@+id/exit3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" 
     android:contentDescription="@string/image" 
     android:layout_alignParentTop="true" 
     android:background="@drawable/exit" 
     /> 
    <TextView 
      android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/tv01" 
    android:background="#000" 
    android:layout_centerHorizontal="true"/> 

    <LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/rl03" 
    android:background="#00ffffff" 
    android:layout_below="@+id/tv01" 
    android:orientation="vertical" 
    > 



     <ImageButton 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/click" 
      android:contentDescription="@string/image" 
      android:paddingTop="20dip" /> 
     <ImageButton 
    android:id="@+id/button2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/click" 
    android:contentDescription="@string/image" 
    /> 
     <ImageButton 
    android:id="@+id/button3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    android:background="@drawable/click" 
    android:contentDescription="@string/image" 
    /> 
     <ImageButton 
    android:id="@+id/button4" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 

    android:background="@drawable/click" 
    android:contentDescription="@string/image" 
    /> 


    </LinearLayout> 



</RelativeLayout> 
    </RelativeLayout> 
+1

你的問題是什麼?你發佈的代碼有什麼問題? – kebs

+0

請填寫完整代碼 –

+0

請原諒我不清楚。我需要調整佈局中心正下方的四個按鈕。但它不能處理我知道的任何佈局或屬性組合 – Rabiya

回答

0

創建一個從LinearLayour或RelativeLayout擴展的新自定義視圖,並將圖像置於其中。如果我理解正確,你想操作按鈕內的圖像。

一旦你有自己的視圖與圖像內的你可以覆蓋點擊,使其行爲像按鈕。