私はFrameLayout
次のようにしています(両方の android:src 属性がフォルダー内の .png ファイルを参照してい/res/drawable
ます):
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frameLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/ivFrame"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/frame" />
<ImageView
android:id="@+id/ivContent"
android:adjustViewBounds="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/content" />
</FrameLayout>
ここで、2 番目のデバッグを行う必要がありますImageView
(これは を参照してい@drawable/content
ます)。この目的のために、次のようにカスタム BitmapDrawable を作成しました。
public class CustomDrawable extends BitmapDrawable {
public CustomDrawable(Resources res, Bitmap bitmap) {
super(res, bitmap);
// TODO Auto-generated constructor stub
}
public CustomDrawable(Resources res, InputStream is) {
super(res, is);
// TODO Auto-generated constructor stub
}
public CustomDrawable(Resources res, String filepath) {
super(res, filepath);
// TODO Auto-generated constructor stub
}
public CustomDrawable(Resources res) {
super(res);
// TODO Auto-generated constructor stub
}
@Override
protected void onBoundsChange(Rect bounds) {
Log.d(Constants.LOG_TAG,"CustomDrawable.onBoundsChanged: "+bounds);
super.onBoundsChange(bounds);
}
}
質問:
CustomDrawable
XML でmy を指定する方法(および使用するように指示する方法@drawable/content
)ImageView
次に、レイアウト XML で に my を指すように指示するにはどうすればよいCustomDrawable
ですか?