这是,什么作品:安卓:FrameLayout里子不画
一)FrameLayout里有两个ImageViews main.xml中
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:id="@+id/frameLayout1"
android:layout_height="wrap_content">
<ImageView android:src="@drawable/radar_background"
android:id="@+id/background" android:layout_width="wrap_content"
android:layout_height="wrap_content"></ImageView>
<ImageView android:src="@drawable/radar_sector" android:id="@+id/sector"
android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</FrameLayout>
B)RotateAnimation在背景上,而前景部分保持不变
因为我需要做的多一点,我把它变成的FrameLayout子类的背景图像上,并改变相应的main.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:id="@+id/frameLayout1"
android:layout_height="wrap_content">
<com.decades.SensorTest.RadarView
android:id="@+id/background" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView android:src="@drawable/radar_sector" android:id="@+id/sector"
android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
</FrameLayout>
这是新RadarView .java:
public class RadarView extends FrameLayout {
private Bitmap mRadar;
public RadarView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public RadarView(Context context) {
super(context);
init();
}
private void init() {
mRadar = BitmapFactory.decodeResource(getResources(), R.drawable.radar_background);
}
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
canvas.drawBitmap(mRadar, 0, 0, null);
}
}
发生了什么:
a)构造函数在setContentView(R.layout.main)中调用;
二)dispatchDraw倍率称为
三)图像不不出现在屏幕上...
是否有人看到了,为什么?
嗨,Erlan,这是一个很好的观点。同时我也遇到了同样的解决方案。有用。谢谢。 – decades 2011-03-04 17:23:45