2013-03-03 120 views
0

我有一个线性布局里面的相对布局,里面的相对布局我有一个图像视图和glsurface堆叠在它上面,我想glsurface具有与imageview相同的大小,如何完成此任务?Android相对布局儿童大小

  <RelativeLayout 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent"> 

       <com.zibi.ResizableImageView 
            android:id="@+id/imageView1" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            android:layout_weight="1.0" 
            android:gravity="center_horizontal" 
            android:src="@drawable/notepad" /> 

       <com.zibi.zGLSurfaceView android:id="@+id/surfaceviewclass" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent"> 

       </com.zibi.travelersnotepad.zGLSurfaceView> 
      </RelativeLayout> 

回答

0

尝试设置layout_align*属性。 TextView将覆盖ImageView。 More about relative layout attributes

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <ImageView 
     android:id="@+id/img" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/image" 
     android:scaleType="fitXY"/> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#AFFF" 
     android:layout_alignRight="@+id/img" 
     android:layout_alignLeft="@+id/img" 
     android:layout_alignTop="@+id/img" 
     android:layout_alignBottom="@+id/img" 
     android:text="sample text"/> 
</RelativeLayout> 
0

您不能使用RelativeLayout强制其中的子视图的大小属性。 如果你不有这方面的特别需要,可以使用的LinearLayout代替,并给予两种观点相同的重量:

  <LinearLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"> 

      <com.zibi.ResizableImageView 
           android:id="@+id/imageView1" 
           android:layout_width="fill_parent" 
           android:layout_height="fill_parent" 
           android:layout_weight="1.0" 
           android:gravity="center_horizontal" 
           android:src="@drawable/notepad" /> 

      <com.zibi.zGLSurfaceView android:id="@+id/surfaceviewclass" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1.0"> 

      </com.zibi.travelersnotepad.zGLSurfaceView> 
     </LinearLayout> 
+0

“我有一个图像视图和glsurface堆放在它上面”,你不能堆放在linear_layout等顶级一种观点认为,这就是为什么我使用相对之一,我想glsurface有相同的大小作为imageview – ZZZ 2013-03-03 10:46:13