2015-09-25 82 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扩展的新自定义视图,并将图像置于其中。如果我理解正确,你想操作按钮内的图像。

一旦你有自己的视图与图像内的你可以覆盖点击,使其行为像按钮。