Search code examples
androidandroid-layoutandroid-cameraandroid-camera-intent

ImageView with camera button at bottom


I am new to android. I have an imageview with camera button at bottom of image view. Whenever the button is clicked,camera should open and capture image.This captured image should be saved in memory and imageview must now display this captured image .Whenver the camera button is clicked,new image must be saved and imageview must display this image. Layout

How to design this type of layout with camera button as placed at the bottom of image view?


Solution

  • Well You can use this layout..

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical"
        tools:ignore="MissingPrefix">
    
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="250dp"
            android:fitsSystemWindows="true"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:src="@drawable/bicycle" />
    
        </android.support.design.widget.AppBarLayout>
    
    
        <android.support.design.widget.FloatingActionButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/margin_5dp"
            android:clickable="true"
            app:fabSize="mini"
            android:src="@android:drawable/ic_menu_camera"
            app:layout_anchor="@id/appbar"
            app:layout_anchorGravity="bottom|right|end" />
    
    </android.support.design.widget.CoordinatorLayout>
    

    Hope it'll help