からクラスをCalloutView
拡張しましたRelativeLayout
。現在、メソッドはありません。コンストラクターを再定義するだけです。
XMLレイアウトもあります。
<?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>
CalloutView
このコードでのインスタンスのレイアウトを膨らませます:
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));
完璧にレンダリングされます。ImageButton
右側に表示されます。
しかし、私が背景を追加すると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>
背景のみをレンダリングしますが、ImageButton
表示されません。
編集
NinePatch画像を背景として使用しています。NinePatch以外に置き換えると、すべて正常に機能します。Androidのバグ?
主な質問は、ImageButton
背景が設定されている場合、なぜレンダリングされないのかということです。