TextView inside a View Class

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

TextView inside a View Class

Postby viju85 » Thu Jan 28, 2010 7:08 am

Hi,
I have a class that extends View Parent Class.
Within the class, I make use of onDraw() to draw an image(sudoku game) on my screen using canvas.
I also want to display a textView(for the scores) below the image in the same screen.

I have tried various ways to do this.
Kindly help as it may save a lot of time.

Thanks,
Vj
viju85
Junior Developer
Junior Developer
 
Posts: 20
Joined: Mon Feb 23, 2009 10:17 pm

Top

Postby KarlKarlsom » Fri Jan 29, 2010 8:52 pm

Without long thinking 3 solutions spring into my mind. Maybe one fits for you.

First:
Why don't you make a Layout (LinearLayout) and put below the SudokuView a Textview.

Second:
Use a FrameLayout to overlap the views (like this example from http://mobiforge.com/designing/story/un ... -1-layouts)
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4. <AbsoluteLayout
  5.  
  6.    android:id="@+id/widget68"
  7.  
  8.    android:layout_width="fill_parent"
  9.  
  10.    android:layout_height="fill_parent"
  11.  
  12.    xmlns:android="http://schemas.android.com/apk/res/android"
  13.  
  14.    >
  15.  
  16.     <FrameLayout
  17.  
  18.        android:layout_width="wrap_content"
  19.  
  20.        android:layout_height="wrap_content"
  21.  
  22.        android:layout_x="40px"
  23.  
  24.        android:layout_y="35px"
  25.  
  26.        >        
  27.  
  28.         <ImageView
  29.  
  30.            android:src = "@drawable/androidlogo"
  31.  
  32.            android:layout_width="wrap_content"
  33.  
  34.            android:layout_height="wrap_content"
  35.  
  36.            />            
  37.  
  38.         <Button
  39.  
  40.            android:layout_width="124px"
  41.  
  42.            android:layout_height="wrap_content"
  43.  
  44.            android:text="Print Picture"      
  45.  
  46.            />
  47.  
  48.     </FrameLayout>
  49.  
  50. </AbsoluteLayout>
  51.  
  52.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Third:
If you want it in the same view like your SodukoView try the Canvas.drawText(String, x, x, paint) function.
KarlKarlsom
Experienced Developer
Experienced Developer
 
Posts: 55
Joined: Mon Dec 14, 2009 8:40 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 2 guests