Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Self-Destructing Message Android App Retrieving and Viewing Messages Using Picasso to View Images from the Web

John Corser
John Corser
5,660 Points

My images are loading in sideways?

When I tap the name of the friend to load the image, it appears sideways rather than filling the screen in portrait.

How can I fix this?

3 Answers

Sam Coles
PLUS
Sam Coles
Courses Plus Student 13,887 Points

John:

Did you manage to fix this problem?

I'm having the same issue.

Images I use from my gallery work fine

Images I take using my camera load up sideways when I view them. (I'm using a Samsung Galaxy S5)

Can you post your code for ViewImageActivity.

Are you running this on a device or the emulator?

Steve.

John Corser
John Corser
5,660 Points

I am running it on my actual phone, an LG G3.

```public class ViewImageActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_image);

    ImageView imageView = (ImageView)findViewById(R.id.imageView);
    Uri imageUri = getIntent().getData();
    Picasso.with(this).load(imageUri.toString()).into(imageView);

    Timer timer = new Timer();

    timer.schedule(new TimerTask() {
        @Override
        public void run() {
            finish();
        }
    }, 10*1000);

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.view_image, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

}

My code has an additional method added - it may be covered in a later section so you may not have missed it!

The method is:

private void setupActionBar() {
    getActionBar().setDisplayHomeAsUpEnabled(true);
}

This method is called from within onCreate after setContentView

I've no idea why we don't just call the getActionBar() from within the onCreate method, but hey!

I hope that helps.

Steve.

I wasn't clear, sorry!

Add, setupActionBar() after the setContentView(R.layout.activity_view_image) line.

Steve. :)

John Corser
John Corser
5,660 Points

It didn't fix my problem. On different devices, the rotation is different as well. For example, on my LG G3, it rotates 270 degrees, on an HTC One, it rotates 90 and on a Samsung Galaxy S3 it rotates 180. I haven't found a phone where it works correctly yet though.