Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.fenchtose.nocropper.CropperView height issue #2

Closed
tuhin10 opened this issue Nov 18, 2015 · 3 comments
Closed

com.fenchtose.nocropper.CropperView height issue #2

tuhin10 opened this issue Nov 18, 2015 · 3 comments

Comments

@tuhin10
Copy link

tuhin10 commented Nov 18, 2015

it seems your are calculating the CropperView based on the width of the view. Now the problem is I'm not able to make the view center in the screen.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity">
<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_frame"
    android:layout_alignParentTop="true" >
    <com.fenchtose.nocropper.CropperView
        android:background="#ff282828"
        android:id="@+id/imageview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:grid_opacity="0.8"
        app:grid_thickness="1.1dp"
        app:grid_color="@color/colorAccent"/>
    <ImageView
        android:id="@+id/snap_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_margin="16dp"
        android:padding="8dp"
        android:layout_gravity="left|bottom"
        android:background="@drawable/black_transp_circ_ripple"
        android:scaleType="center"
        android:src="@mipmap/ic_crop_free_white_24dp"/>
    <ImageView
        android:id="@+id/rotate_button"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:padding="8dp"
        android:layout_margin="16dp"
        android:layout_gravity="right|bottom"
        android:background="@drawable/black_transp_circ_ripple"
        android:scaleType="center"
        android:src="@mipmap/ic_rotate_right_white_24dp"/>
</FrameLayout>
<LinearLayout
    android:id="@+id/bottom_frame"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:background="#ff212121"
    android:padding="9dp"
    android:layout_alignParentBottom="true"
    android:gravity="center_vertical"
    android:orientation="horizontal">
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Upload Image"
        android:id="@+id/image_button"/>
    <Button
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="Crop"
        android:id="@+id/crop_button"/>
</LinearLayout>
</RelativeLayout>

screenshot_2015-11-19-02-18-49

@tuhin10
Copy link
Author

tuhin10 commented Nov 18, 2015

I want to remove the white space between lower buttons and crop view, by center aligning the cropview.

@jayrambhia
Copy link
Owner

You're right. It does calculate height based on the width to make it square. Maybe it wouldn't work properly in Landscape mode. You can solve your problem by changing your layout.

If you want to keep the cropper in center, use layout_gravity="center" and since it is a square, you would want your FrameLayout height to wrap_content.

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/bottom_frame"
android:layout_alignParentTop="true" >
<com.fenchtose.nocropper.CropperView
    android:background="#ff282828"
    android:id="@+id/imageview"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_gravity="center"
    app:grid_opacity="0.8"
    app:grid_thickness="1.1dp"
    app:grid_color="@color/colorAccent"/>
<ImageView
    android:id="@+id/snap_button"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:layout_margin="16dp"
    android:padding="8dp"
    android:layout_gravity="left|bottom"
    android:background="@drawable/black_transp_circ_ripple"
    android:scaleType="center"
    android:src="@mipmap/ic_crop_free_white_24dp"/>
<ImageView
    android:id="@+id/rotate_button"
    android:layout_width="40dp"
    android:layout_height="40dp"
    android:padding="8dp"
    android:layout_margin="16dp"
    android:layout_gravity="right|bottom"
    android:background="@drawable/black_transp_circ_ripple"
    android:scaleType="center"
    android:src="@mipmap/ic_rotate_right_white_24dp"/>
</FrameLayout>

@jayrambhia
Copy link
Owner

Closed in favor of #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants