1

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.

  1. Add ListView in Dialog, but the screen is dark, which I don't want it to be.

  2. 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 :(

barssala
  • 463
  • 2
  • 6
  • 22
  • 1
    First way deffenately better, you could style `Dialog` to become borderless and with translucenbt background. Check [this](http://stackoverflow.com/a/6059132/1705641) link. – Evos Jan 29 '13 at 08:44
  • Thanks you so much, now I can show my list view :) – barssala Jan 29 '13 at 08:52
  • I moved my comment to answer so youi can upvote and/or check it as a correct one. You're welcome! – Evos Jan 29 '13 at 09:19

2 Answers2

1

+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.

Leonidos
  • 10,482
  • 2
  • 28
  • 37
1

First way deffenately better, you could style Dialog to become borderless and with translucenbt background. Check this link.

Community
  • 1
  • 1
Evos
  • 3,915
  • 2
  • 18
  • 21