2013-03-03 4 views
0

У меня есть относительный макет внутри линейного макета, внутри относительной компоновки. У меня есть изображение и glururface, уложенные поверх него, я хочу, чтобы glsurface имел тот же размер, что и изображение, как выполнить эту задачу?Относительное расположение детей от детей

  <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 иметь одинаковый размер как изображение – ZZZ

Смежные вопросы