I have an activity which is set up in the LANDSCAPE mode becuase there I’m setting up a picture taken from the camera.The problem is that I want to put a button on the top of this activity in order to upload the picture to a website.
Here is a piece of relevant code:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);requestWindowFeature(Window.FEATURE_NO_TITLE);getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
....
}
and here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/uploadBtn"
android:text="Upload picture"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:id="@+id/myPic"
/>
</LinearLayout>
And here is the result:
http://i55.tinypic.com/10h4xzr.png
Now I want the button to be on the top of my screen not on the right side!Does someone what should I do?
The problem, as I’m sure you know, is that you have set the screen orientation in to landscape – so this button is in the correct orientation for the screen.
So, first thing to try is to set it in portrait mode and see if you get the correct functionality (for the button and the enclosing activity). I’m sure you’re tried this, but it’s worth pointing out.
It looks like you’re using non-standard buttons, so why not write a class which renders text to a bitmap, rotate it to the correct orientation and then set that as the background to a button?