Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7636671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:44:29+00:00 2026-05-31T07:44:29+00:00

I am developing a application where i want, user can practice the English alphabets,clicking

  • 0

I am developing a application where i want, user can practice the English alphabets,clicking on “Practice” button.I got a reference here but this code is not working. I am new to android.Can anyone help me with code,how I can do this.

    import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.FontMetricsInt;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class AlphaDraw extends View {

   public interface AlphaScrollable {
      public void scrollAlpha(char prefix);
   }

   public AlphaScrollable target;

   public AlphaDraw(Context context) {
      super(context);
   }

   public AlphaDraw(Context context, AttributeSet attrs) {
      super(context, attrs);
   }

   public AlphaDraw(Context context, AttributeSet attrs, int defStyle) {
      super(context, attrs, defStyle);
   }

   protected String[] alpha = new String[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
            "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };

   protected boolean touching = false;

   // try capturing touches to jump to letters
   // will actively adjust list location
   @Override
   public boolean onTouchEvent(MotionEvent event) {

      float margin = this.getWidth() / 4;
      float fracy = (event.getY() - (margin * 2)) / (this.getHeight() - (margin * 4));

      int approx = (int) (alpha.length * fracy);
      // Log.d("ALPHA", String.format("approx=%s", alpha[approx]));

      if (approx < 0 || approx >= alpha.length)
         return true;

      // jump to alpha location in list

      // find first letter location in list
      this.target.scrollAlpha(alpha[approx].charAt(0));

      switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
         this.touching = true;
         this.invalidate();
         break;

      case MotionEvent.ACTION_UP:
         this.touching = false;
         this.invalidate();
         break;

      }

      return true;

   }

   @Override
   protected void onDraw(Canvas canvas) {

      // show shadow only when being actively touched

      float width = this.getWidth(), height = this.getHeight();
      float margin = this.getWidth() / 4;

      float spacing = (height - (margin * 4)) / alpha.length;

      int shadowColor = Color.argb(128, 0, 0, 0);
      GradientDrawable shadow = new GradientDrawable(Orientation.LEFT_RIGHT, new int[] { shadowColor, shadowColor });
      shadow.setShape(GradientDrawable.RECTANGLE);
      shadow.setCornerRadius(10);

      shadow.setBounds((int) margin, (int) margin, (int) (width - margin), (int) (height - margin));

      if (touching)
         shadow.draw(canvas);

      // draw alphabet index
      // remember that text is drawn from bottom

      Paint paint = new Paint();
      paint.setColor(Color.argb(255, 255, 255, 255));
      paint.setFakeBoldText(true);
      paint.setFlags(Paint.ANTI_ALIAS_FLAG);

      // measure to figure out perfect text height
      // W is a nice average letter
      // read new metrics to get exact pixel dimensions
      FontMetricsInt fm = paint.getFontMetricsInt();
      // float charHeight = Math.abs(fm.top) + Math.abs(fm.descent);
      float startTop = (margin * 2) + Math.abs(fm.top);

      for (int i = 0; i < alpha.length; i++) {
         float charWidth = paint.measureText(alpha[i]);
         float centered = (width - charWidth) / 2;

         canvas.drawText(alpha[i], centered, (i * spacing) + startTop, paint);

      } 
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:44:31+00:00Added an answer on May 31, 2026 at 7:44 am

    best would be to create a activity that would display the alphabet
    draw a transparent canvas on that and let user draw on top of that canvas
    seeing through transparent film over the activity

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a Java Desktop Application and want a light database that can
I'm developing wp7 Mango application. I run PeriodicTask and want to notify user according
I'm developing an iPhone application and I'm trying to do this: I want an
I am developing a Java Desktop Application. In the GUI, I want that user
I hope this question belongs here. I am developing a web application for a
I am currently developing an android application. I want the user to select an
I am developing Application in android I want to show AlertDialog if user check
I'm currently developing my first android application. I want the user of my application
I am developing a simple online suggestion application where the user can fill a
Hi i am developing an application and i want the user to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.