Reputation: 483
now I use canvas(ondraw()
) to draw images of my app and if I want to show some
list in center of my app. What should I suppose to do? I have 2 ideas.
Add ListView in Dialog, but the screen is dark, which I don't want it to be.
Add ListView in LinearLayout and make it to Bitmap
which I can't draw image, my
code is this following:
ListView modeList = new ListView(context);
modeList.setAdapter(new ImageAdapter(context, objects));
linearlayout = new LinearLayout(context);
linearlayout.setOrientation(LinearLayout.VERTICAL);
linearlayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
linearlayout.addView(modeList);
linearlayout.layout(0, 0, 200, 200);
linearlayout.measure((int)Define.getScreenWidth(), (int)Define.getScreenHeight());
linearlayout.setDrawingCacheEnabled(true);
linearlayout.buildDrawingCache(true);
and when I draw
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(linearlayout.getDrawingCache(), 200, 200, null);
}
However, it draws nothing :(
Upvotes: 1
Views: 1285
Reputation: 3915
First way deffenately better, you could style Dialog to become borderless and with translucenbt background. Check this link.
Upvotes: 1
Reputation: 10518
+1 vote for the first way. Style your dialog and disable dark background.
Second way is overcomplicated. You better add listview as a child directly to a current window, so it will be drawn on top of all other views, or place all your views in framelayout and add listview to that framelayout, so it will be on top of all previously added views.
Upvotes: 1