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

  • Home
  • SEARCH
  • 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 7414351
In Process

The Archive Base Latest Questions

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

I’m writing a custom camera application which follow this tutorial: http://marakana.com/forums/android/examples/39.html Now I’m able

  • 0

I’m writing a custom camera application which follow this tutorial:
http://marakana.com/forums/android/examples/39.html

Now I’m able to use the camera and get the image data after user click a button.
But I got the problem that the preview is sideway so I add the following code in surfaceCreated

@Override
public void surfaceCreated(SurfaceHolder holder) {
    //  Open the camera when the preview is created
    Log.d("Callback", "[surfaceCreated]");
    theCamera = Camera.open();

    Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();
    int displayRotation = display.getRotation();
    switch (displayRotation)  {
        case Surface.ROTATION_0:        theCamera.setDisplayOrientation(90);    break;
        case Surface.ROTATION_90:       break;
        case Surface.ROTATION_180:      break;
        case Surface.ROTATION_270:      theCamera.setDisplayOrientation(180);   break;
    }
}

The preview was fine.
However when I got the image data, I use BitmapFactory.decodeByteArray to get the bitmap, and set it to my imageView that is defined in my xml layout.

Here is my main.xml

<SurfaceView
    android:id="@+id/previewSurfaceView"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="center" />

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="250px" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="Button" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:maxHeight="100dp"
        android:maxWidth="100dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="fill_parent"
    android:layout_height="250px" >

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:text="Button" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center_vertical"
        android:layout_weight="1"
        android:maxHeight="100dp"
        android:maxWidth="100dp"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_launcher" />

</LinearLayout>

previewSurfaceView is the small view that for the camera preview

button1 and button2 are the button when I clicked on, the camera capture the image and set the imagedata corresponding to imageView1/imageView2

There are some problems:

  1. I set the layout width and height and also the max width and height to 100dp, also the scale type to fitCenter. But it seems not to display as what I want. I want the image is show inside the bound. Am I doing wrong in the layout setting?

  2. The image is always in landscape even I took the picture in portrait mode.

Besides, I want to add a button to toggle the on/off of camera but I can’t figure out how to do this.

Can somebody suggest the solution for me? Thank you.

  • 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-29T07:05:14+00:00Added an answer on May 29, 2026 at 7:05 am

    Have a look at my answer here as it appears to be the same issue you are having.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string

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.