Mirrored TextView

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Mirrored TextView

Postby MichaMicha » Tue Mar 31, 2009 1:02 pm

Hi,
I want to create a TextView with the text mirrored vertically.
I tried this code, but it doesn't show anything...

Does anyone have an idea?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. /** Called when the activity is first created. */
  5.  
  6.         @Override
  7.  
  8.         public void onCreate(Bundle savedInstanceState) {
  9.  
  10.                 super.onCreate(savedInstanceState);
  11.  
  12.  
  13.  
  14.                
  15.  
  16.  
  17.  
  18.                 setContentView(R.layout.main);
  19.  
  20.  
  21.  
  22.                 rl = (RelativeLayout) findViewById(R.id.Rellayout);
  23.  
  24.  
  25.  
  26.                 MirrorView speed = new MirrorView(getBaseContext());
  27.  
  28.  
  29.  
  30.                 speed.setText("Testtest");
  31.  
  32.  
  33.  
  34.                 rl.addView(speed);
  35.  
  36.  
  37.  
  38.  
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.         private class MirrorView extends TextView {
  47.  
  48.  
  49.  
  50.                 public MirrorView(Context context) {
  51.  
  52.                         super(context);
  53.  
  54.                         // TODO Auto-generated constructor stub
  55.  
  56.                 }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                 @Override
  63.  
  64.                 protected void onDraw(Canvas canvas) {
  65.  
  66.  
  67.  
  68.  
  69.  
  70.                         canvas.scale((float) -1.0f, (float) 1.0f, (float) (canvas
  71.  
  72.                                         .getWidth() / 2), (float) (canvas.getHeight() / 2));
  73.  
  74.                         super.onDraw(canvas);
  75.  
  76.                 }
  77.  
  78.         }
  79.  
  80.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
MichaMicha
Freshman
Freshman
 
Posts: 3
Joined: Sun Dec 28, 2008 3:44 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 1 guest