views:

35

answers:

1

I am writing an android application and am having problems with overlapping views. My layout is

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>
   <TextView  
       ...
   />
   <EditText
       ...
   />
   <Button
       ...
   />
   <Button
       ...
   />
   <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
   >
   <SurfaceView
       android:id="@+id/surface_view"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
    />
    <CustomView
       android:id="@+id/custom_view"
       android:background="#0000"
       android:layout_alignTop="@id/surface_view"
       android:layout_alignBottom="@id/surface_view"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
    />
    </RelativeLayout>
</LinearLayout>

As you can see I am trying to overlap surface_view and custom_view. Only custom_view is shown on screen. If I define custom_view first and then surface_view, then only surface_view is shown but custom_view methods are being called as I could see log messages in adb logcat. Am I missing some thing.

The same above layout ( overlapping ) works fine in a different project.

Any thoughts would be helpful. Thanks.

A: 

As you can see I am trying to overlap surface_view and custom_view. Only custom_view is shown on screen. If I define custom_view first and then surface_view, then only surface_view is shown but custom_view methods are being called as I could see log messages in adb logcat. Am I missing some thing.

They are both set to fill the parent in the X and Y dimensions. And, they are both set to go in the upper-left corner of the parent. Hence, you will only see the second one.

CommonsWare