Hi, I am creating a camera app and my first activity is like snapchat.
I followed the instructions for installing the camera for Android ( https://developer.android.com/guide/topics/media/camera.html ).
But, unfortunately, it did not cover the specific type of button that I want (snapchat as a button).
I want to have buttons like snapchat.
Here is my current xml view:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/camera_preview"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1" >
<Button
android:id="@+id/button_capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_vertical|center_horizontal"
android:text="capture" />
</FrameLayout>
</LinearLayout>
And my mainactivity java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
mCamera = getCameraInstance(getApplicationContext());
mPreview = new CameraPreview(this, mCamera);
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);
Button captureButton = (Button) findViewById(R.id.button_capture);
captureButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCamera.takePicture(null, null, mPicture);
}
});
}
I believe that the problem arises because after rendering the xml-layout, the tutorial adds
preview.addView(mPreview);
Above the layout, which, in my opinion, a camera preview is drawn above the button.
I was only thinking of two solutions to this.
.addView(mPreview); . - z-, xml- ?
snapchat - ? , , , snapchat.
.