I have class CalloutView
extended from RelativeLayout
. Currently has no any methods, it just redefines constructors.
I also have an XML layout for it:
<?xml version="1.0" encoding="utf-8"?>
<com.example.CalloutView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp">
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:background="@drawable/button_disclose"
android:src="@drawable/disclose" />
</com.example.CalloutView>
I inflate layout of instance of CalloutView
by this code:
this.calloutView = (CalloutView) ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.callout_view, null);
this.calloutView.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 105));
this.calloutView.measure(MeasureSpec.makeMeasureSpec(400, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(105, MeasureSpec.EXACTLY));
It renders perfectly. ImageButton
appears on the right side of it like it should.
But when I add a background to CalloutView
:
<com.example.CalloutView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:background="@drawable/callout">
...
</com.example.CalloutView>
It renders only background, but ImageButton
doesn't appear.
Edit
I use NinePatch image as a background. If I replace it with non-NinePatch everything works fine. Bug in Android?
The main question is, why it ImageButton
isn't rendered, if background is set?