2016-08-12 6 views
0

私のアプリでは、顔を撮影して別の場所に移動するまで削除しないと表示できません。最初にアプリを開いたときに起こっていることは、レイアウトのバックグラウンドのピンクのサイドラインが表示されていることですが、写真を撮るとピンクのラインが消えてしまいます。私はbackroundのビットマップを設定していますImageViewの幅と高さにmatch_parentされたので、これは起こるはずのImageViewが画面の両面にフィットしない

第二の問題は、私は戻って、背景に背景ImageViewのを設定するときに前の中央に透明であるということであるので、私はそれを戻しても、カメラが指している場所が見えないことがわかります。画面は透明な中心に戻りますが、takePictureが実行されたときに撮影されたスクリーンショットはそのままです。任意の助けてくれてありがとう私は今、私の髪をリッピングしていますよう

enter image description here

background_view = (ImageView) view.findViewById(R.id.backround_view); 
      background = BitmapFactory.decodeResource(getResources(), R.drawable.camera_backround); 
      background_view.setImageBitmap(background); 

private void takePicture() { 
     if (picturePresent == false) { 
      edit_button.setVisibility(View.INVISIBLE); 

      pictureBitmap = getBitmapFromView(); 

      edit_button.setVisibility(View.VISIBLE); 

      closeCamera(); 
      stopBackgroundThread(); 

      BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), pictureBitmap); 
      background_view.setBackground(bitmapDrawable); 
      picturePresent = true; 

     } else { 
     } 
    } 


    private void deletePicture() { 
     if (picturePresent == true) { 
      startBackgroundThread(); 
      openCamera(mTextureView.getWidth(), mTextureView.getHeight()); 
      background_view.setImageBitmap(background); 
      picturePresent = false; 
     } else { 
     } 
    } 

    public Bitmap getBitmapFromView() { 
     Bitmap bitmap = mTextureView.getBitmap(); 
     Bitmap bitmap2 = BitmapFactory. decodeResource(getResources(), R.drawable.camera_backround); 
     Bitmap bmOverlay = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); 
     Canvas canvas = new Canvas(bmOverlay); 
     canvas.drawBitmap(bitmap, new Matrix(), null); 
     canvas.drawBitmap(bitmap2, new Matrix(), null); 
     return bmOverlay; 
    } 

XML

<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" 
      tools:context="yourfacelivewallpaper.alexcz.yourfacelivewallpaper.CameraFragment" 
       android:background="#ffbf1ec5"> 

    <!-- TODO: Update blank fragment layout --> 

    <view 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     class="yourfacelivewallpaper.alexcz.yourfacelivewallpaper.AutoFitTextureView" 
     android:id="@+id/texture" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true"/> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/backround_view" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" 
     android:longClickable="false" 
     android:layout_alignParentEnd="true" 
     android:layout_alignParentStart="true"/> 

答えて

1

アンドロイド:scaleType = "fitXY"

xmlファイル内のコードの上に追加します。

0

あなたの画像が小さく番目の場合あなたのImageViewは画面に表示されません。 ImageViewのレイアウトプロパティにandroid:scaleType="fitCenter"を追加する必要があります。

関連する問題