This is my code with FrameLayout :
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/frameView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/image1" /> </FrameLayout>
ImageView shows well.
Now I have a custom layout extending from FrameLayout, for example. MyFrameLayout.
In MyFrameLayout, I want the layout height to always be half the width, so my code is:
public class MyFrameLayout extends FrameLayout {
Then use it in xml:
<com.test.MyFrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageView android:id="@+id/frameView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/image1" /> </com.test.MyFrameLayout>
But now the internal ImageView is gone.
I think that I am not implementing onMeasure or onLayout correctly. I guess I also need to resize the views of children. But I do not know what to do now.
UPDATE
In TheDimasig's comment , I just checked my code and updated my question. Thanks
Freewind
source share