Reputation: 27211
I overrided RelativeLayout class by a new one:
public class myRelative extends RelativeLayout{
//...
//this function is called but layout is not filled
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
}
//...
}
the XML file looks like this:
<myRelative
android:id="@+id/someid"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
....
</....>
The behaviour of this Layout is the same as usual RelativeLayout
? Why nothing changed? Any ideas?
Upvotes: 1
Views: 148
Reputation: 16537
Layouts have special optimization. If there's no background set, onDraw is not called, because layout is supposed to be an empty view. Only dispatchDraw is called every time.
Upvotes: 1
Reputation: 1266
Try to set setWillNotDraw(false);
in all constructors of your custom view. Or maybe your custom view placed in xml where parent view have also WHITE
background.
Upvotes: 2