I’m rolling my own camera app and for that I’m using a SurfaceView with Landscape orientation as standard.
What I’m trying to do is, inflate the SurfaceView to have a button. But I want the button to appear centred at the bottom of portrait orientation, like most stock camera apps. The layout for button that I’m inflating is as below, I’m not sure what combination of controls will give me the desired result.
My Layout:
<?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:gravity="right"
>
<Button
android:id="@+id/takepicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" * Take Picture "
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="10px"
/>
</LinearLayout>
Thanks for your help! =]
Thanks Ares, for your answer. I dug around a bit more on here, and found a solution with LinearLayout, but from what I understand, everything has its place but in general RelativeLayout gives better performance, so I experimented a bit, and I got this now, which works for me. Please note, I’m using an image as the button, so you’d probably want to upgrade it include other buttons on press etc and scale it appropriately (which is what I will do next). But in barebones, this is what is working for me.
The above is inflated on my SurfaceView, which I declare like this :
}
Hope this helps.