[英]Edmodo android image cropper, fix aspect ratio
我在android棒棒糖上使用edmodo / cropper庫時遇到一些問題。 我的應用程序應該拍攝一些圖片,並且在拍攝完每張圖片之后,用戶應裁剪正方形圖像。 這是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.example.newapicamera.AutoFitTextureView
android:id="@+id/texture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/footer" />
<com.edmodo.cropper.CropImageView
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:id="@+id/CropImageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/footer"
android:visibility="invisible" />
<ImageView
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:src="@drawable/footer" />
<TextView
android:id="@+id/current_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:textColor="#FFFFFF"
android:textSize="30sp" />
這就是我在拍照后啟動作物庫的方式;
crop_view.setImageBitmap(bitmap);
mCameraDevice.close();
mTextureView.setVisibility(View.INVISIBLE);
crop_view.setVisibility(View.VISIBLE);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
int dpWidth = displayMetrics.widthPixels;
crop_view.setFixedAspectRatio(true);
crop_view.setAspectRatio(dpWidth, dpWidth);
我有一個后續的問題:
我遇到了同樣的問題,以下解決方案對我有效:
cropImageView.setFixedAspectRatio(true);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
cropImageView.setAspectRatio(7, 7);
}
}, 500);
此問題是一個錯誤,現在您可以使用新版本,此問題已得到解決。 目前,新版本為2.0.0 ,但很遺憾,cropper Wiki上未提及該版本 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.