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 8948847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:05:58+00:00 2026-06-15T13:05:58+00:00

I am building a custom camera with auto focus, and was merely wondering if

  • 0

I am building a custom camera with auto focus, and was merely wondering if there is a way to invoke the same auto-focus rectangular indicator that the native camera has or if i have to build that from scratch.. any examples or tutorial links would be greatly appreciated.

  • 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-06-15T13:05:59+00:00Added an answer on June 15, 2026 at 1:05 pm

    It might be helpful to look at the way the most recent Jelly Bean 4.2 camera handles this. You can download the Camera source as follows:

    git clone https://android.googlesource.com/platform/packages/apps/Camera.git
    

    Once you have the code, navigate to the FocusOverlayManager class and the PieRenderer class. If you haven’t tried out this newest version before, the focus meter is a pie-like circle that rotates upon focus completion. You can make your own square in photoshop or use one of these two that I have used in the past (one is an iPhone ripoff I made and the other is a nine-patch used in some version of the android camera):

    enter image description here enter image description here

    The Jelly Bean example may be a little complicated for what you are looking for, so below are some guidelines for the way I implemented visual feedback for autofocus. The process can be somewhat complicated. I don’t pretend my way is the best way to do this, but here is some example code that gives you the general idea…

    In my camera preview layout xml file:

    <!-- Autofocus crosshairs -->
    
    <RelativeLayout
        android:id="@+id/af_casing"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_centerInParent="true"
        android:clipChildren="false" >
    
        <com.package.AutofocusCrosshair
            android:id="@+id/af_crosshair"
            android:layout_width="65dp"
            android:layout_height="65dp"
            android:clipChildren="false" >
        </com.package.AutofocusCrosshair>
    </RelativeLayout>
    

    This AutofocusCrosshair class is the following:

    public class AutofocusCrosshair extends View {
    
        private Point mLocationPoint;
    
        public AutofocusCrosshair(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        private void setDrawable(int resid) {
            this.setBackgroundResource(resid);
        }
    
        public void showStart() {
            setDrawable(R.drawable.focus_crosshair_image);
        }
    
        public void clear() {
            setBackgroundDrawable(null);
        }
    
    }
    

    And when, in my activity, I want to start autofocus I do the following:

    mAutofocusCrosshair = (AutofocusCrosshair) findViewById(R.id.af_crosshair);
    //Now add your own code to position this within the view however you choose
    mAutofocusCrosshair.showStart();
    //I'm assuming you'll want to animate this... so start an animation here
    findViewById(R.id.af_casing).startAnimation(mAutofocusAnimation);
    

    And make sure at the end of your animation to clear the image:

    mAutofocusAnimation.setAnimationListener(new AnimationListener() {
        @Override public void onAnimationEnd(Animation arg0) {
            mAutofocusCrosshair.clear();            
        }
        @Override public void onAnimationRepeat(Animation arg0) {}
        @Override public void onAnimationStart(Animation arg0) {}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a custom RTE that converts user input to a homebrewn markup, now
I’m building a custom robotish machine that has 8 switches I need to interface
I am building a custom camera app, and would like to have the camera
I am building an app that shows the camera ( ImagePickerController ) when the
I'm building a custom ItemsControl in Silverlight that (amongst other things) allows items to
I'm building custom content filtering system using custom radio buttons. There are some problems
I am building an Android app that uses the phone's camera feature. I know
I'm building a custom control for Windows Phone 7+ that can do augmented reality
I was wondering what the purpose of the function onSizeChanged() is while building custom
I'm building a custom view with an xib file that contains various subcontrols. I've

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.