what I want to do is as following: I have a set of Drawables (eg. 16) that I have to combine in different ways (Icon with 1, 2, 3 or 4 Drawables), depending on buisness logic. My idea was to define RelativeLayouts with ImageViews inside. Unfortunately I planned to take these Layouts as an OverlayItem (needs a Drawable) to show them on a MapView. I thought that any Layout is Drawable, but it isn't. I don't find a way to convert this RelativeLayout to a drawable. I really don't get the main difference. Isn't it right that any VIEW can be DRAWN? Can I group multiple Drawables into one? I'm really a beginner on 2D Graphics and got no clue how to solve this. Any idea appreciated
ADD: Code Sample based on the first answer:
public class MapViewActivity extends MapActivity {
MapView mMapView;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCrea开发者_StackOverflow社区te(savedInstanceState);
setContentView(R.layout.map_view);
mMapView = (MapView)findViewById(R.id.mapview);
mMapView.setBuiltInZoomControls(true);
List<Overlay> mapOverlays = mMapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.one_drawable);
//this is where exception is thrown
}
}
and the file one_drawable.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/item_one"
android:top="0dip"
android:right="0dip"
android:bottom="0dip"
android:left="0dip"/>
</layer-list>
So I cannot see any mistake (I set the drawables programatically in my Program)
EDIT 2: OK I'm not allowed to do that. I have to set up a drawable, which can be exchanged later
in spite of any View could be drawn, it is not a drawable. You should use Layer List to operate several pictures as one drawable.
精彩评论