2016-09-17 1 views
0

의 스크린 샷을 : 두 textviews가 겹치는나는이 양식에 내 레이아웃 XML이 중첩 된 RelativeLayout의

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical"> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/ 
    res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:background="#3fb399" 
     tools:context="com.sparrowred.cardsender.customizeCard"> 

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/ 
     res/android" 
      android:id="@+id/relativeViewPrint" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:orientation="vertical" 
      android:weightSum="1" 
      android:layout_above="@+id/button_send" 
      android:layout_alignParentStart="true" 
      android:layout_below="@+id/add_button"> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="180dp" 
       android:id="@+id/textView_wish_card" 
       android:textAlignment="center" 
       android:textSize="20sp" 
       android:layout_weight="0.06" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentStart="true" /> 

      <TextView 
       android:layout_width="149dp" 
       android:layout_height="112dp" 
       android:background="@drawable/image0" 
       android:layout_gravity="center" 
       android:alpha="0.4" 
       android:id="@+id/textView_wish_cardBack" 
       android:layout_weight="0.75" 
       android:layout_alignTop="@+id/textView_wish_card" 
       android:layout_alignParentStart="true" 
       android:layout_alignParentBottom="true" 
       android:layout_alignParentEnd="true" /> 

     </RelativeLayout> 

    </RelativeLayout> 

</LinearLayout> 

. 하나는 이미지 (투명도가있는 이미지)와 다른 이미지, 색상 및 텍스트를 보유합니다 (이 때문에 하나의 RelativeLayout에 겹쳐서 표시). 이 RelativeLayout의 스크린 샷을 얻고 싶습니다. 이 방법을 사용했지만 작동하지 않습니다. 어떤 도움을 주시겠습니까? 54 :

private void ScreenShot2(){ 
    Display display = getWindowManager().getDefaultDisplay(); 
    Point size = new Point(); 
    display.getSize(size); 
    RTLout.measure(View.MeasureSpec.makeMeasureSpec(0, 
    size.x), View.MeasureSpec.makeMeasureSpec(0, size.y)); 
    RTLout.layout(0, 0, RTLout.getWidth(), RTLout.getHeight()); 
    RTLout.setDrawingCacheEnabled(true); 
    RTLout.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH); 
    Bitmap b = Bitmap.createBitmap(RTLout.getDrawingCache()); 
    RTLout.setDrawingCacheEnabled(false); 
    if(b !=null) { 
     try { 
      String extr = Environment.getExternalStorageDirectory(). 
      getAbsolutePath().toString() + File.separator + "Pictures" 
      + File.separator + "Screenshots"; 
      File dir = new File(extr); 
      if (!dir.exists()) 
       dir.mkdirs(); 
      String fileName = 
      new SimpleDateFormat("yyyyMMddhhmm'_report.jpg'"). 
      format(new Date()); 
      File myPath = new File(dir, fileName); 
      FileOutputStream fos = null; 
      try { 
       fos = new FileOutputStream(myPath); 
       b.compress(Bitmap.CompressFormat.JPEG, 100, fos); 
       fos.flush(); 
       fos.close(); 
       MediaStore.Images.Media.insertImage(getContentResolver(), 
       b, "Screen", "screen"); 
      } catch (FileNotFoundException e) { 
       e.printStackTrace(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     }catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
} 

이 방법은 ...... 09-17 16 내가 찾은 일부 코드의 혼합입니다 12.452 : W/시스템 (4926) : 클래스 로더 참조 알 수없는 경로 :/데이터/응용 프로그램/com.sparrowred.cardsender-1/lib/arm64 09-17 16 : 54 : 12.670 : W/art (4926) : Android 4.1 이전에는 android.graphics.PorterDuffColorFilter 및 android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter 메소드가 필요합니다. android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff $ Mode)가 android.graphics.drawable.Drawable의 package-private 메소드를 잘못 재정의했습니다. 09-17 16 : 54 : 12.796 : I/System (4926) : core_booster, getBoosterConfig = false 09-17 16 : 54 : 12.869 : I/Sys E/HAL (4926) :로드 : ID (0) :09-17 16 : 54 : 13.246 : I/HwSecImmHelper (4926) : core_booster, getBoosterConfig = false 09-17 16 : 54 : 13.232 : 16 : 54 : 13.314 : E/HAL (4926) : 부하 : gralloc! = hmi-> id = gralloc 09-17 16 : 54 : 13.315 : I/OpenGLRenderer (4926) : 초기화 된 EGL, 버전 1.4 09-17 16 : 54 : 13.322 : W/OpenGLRenderer (4926) :로드 : so =/system/lib64/libhwuibp.so 09-17 16 : 54 : 13.322 : W/OpenGLRenderer (4926) : dlopen 실패 : 라이브러리 "/system/lib64/libhwuibp.so"을 찾을 수 없음 09-17 16 : 54 : 13.322 : W/OpenGLRenderer (4926) : 이진 프로그램 캐시 초기화 :로드 실패 09 -17 16 : 54 : 13.322 : E/HAL (4926) :로드 : id = gralloc! = hmi-> id = gralloc 09-17 16 : 54 : 13.456 : I/HwSec ImmHelper는 (4926) mSecurityInputMethodService가 null 09-17 16 : 54 : 17.773 : I은/HwSecImmHelper은 (4926)은 54 : 18.189 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09이다 mSecurityInputMethodService는 09-17 16 널 (4926) : mSecurityInputMethodService가 null 09-17 16 : 54 : 20.195 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null 09-17 16 : 54 : 20.218 : I/HwSecImmHelper (4926) 시스템 (4926) : core_booster, getBoosterConfig = false 09-17 16 : 54 : 20.286 : I/System (4926) : core_booster, getBoosterConfig = false 09-17 16 : 54 : 20.635 : W/Settings (4926) : 설정 airplane_mode_on이 android.provider.Settings.System에서 android.provider.Settings.Global으로 이동하여 읽기 전용 값을 반환했습니다. 09-17 16:54:20.655 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 20.842 : I/System (4926) : core_booster, getBoosterConfig = false 09-17 16:54 : (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 22.137 : I/HwSecImmHelper (4926) 20.906 : I/System (4926) : core_booster, getBoosterConfig = false 09-17 16 : 54 : 21.452 : : 54 : 22.137 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 : 54 : 22.238은 : E가/SpannableStringBuilder (4926)는 : mSecurityInputMethodService는 09-17 16 널 SPAN_EXCLUSIVE_EXCLUSIVE 스팬는 제로 길이를 가질 수 09 -17 16 : 54 : 22.238 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위의 길이가 0 일 수 없음 09-17 16 : 54 : 25.969 : I/Hw SecImmHelper는 (4926) mSecurityInputMethodService가 null 09-17 16 : 54 : 26.647 : I은/HwSecImmHelper은 (4926)은 54 : 27.986 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09이다 mSecurityInputMethodService는 09-17 16 널 -17 16:54:28.118 : 입/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 : 54 : 28.128 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 : 54 : 28.158 : I/HwSecImmHelper (4926) mSecurityInputMethodService N/A/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 28.193 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위의 길이가 0 일 수 없음 09-17 16 : 54 : 28.193 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위의 길이가 0 일 수 없음 09-17 16 : 54 : 29.363 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null 09-17 16 : 54 : 30.134 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 30.142 : I/HwSecImmHelper (4926) : mSecurityInputMet hodService가 null입니다. 09-17 16 : 54 : 30.170 : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 30.170 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16:54 : 30.209 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 스팬의 길이가 0 일 수 없음 09-17 16:54:30.209 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 스팬 길이가 0 일 수 없음 09-17 16 : 54 : 30.814 : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 31.279 : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 32.477 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 있습니다. null 09-17 16 : 54 : 32.587 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다.(4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 32.627 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 32.627 :3210 09-17 16 : 54 : 32.596 : SPAN_EXCLUSIVE_EXCLUSIVE 길이가 0 일 수 없음 09-17 16 : 54 : 32.656 : E/SpannableStringBuilder (4926) : mSecurityInputMethodService가 null입니다. : 54 : 33.375 : I가/HwSecImmHelper가 (4926)가 54 : 33.756 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09이다 mSecurityInputMethodService가 09-17 16 널 SPAN_EXCLUSIVE_EXCLUSIVE 스팬 길이 제로 09-17 16을 가질 수 없다 -17 16 : 54 : 34.710 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 34.836 : I/HwSecImmHelper (4926) mSecurityInputMethodService가 null 09-17 16 : 54 : 34.853 : I은/HwSecImmHelper은 (4926)은 54 : 34.883 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 mSecurityInputMethodService는 09-17 16 널 : 54 : 34.884 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 34.912 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위의 길이가 0이 될 수 없음 09-17 16 : 54 : 34.912 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 길이가 0 일 수 없습니다. 09-17 16 : 54 : 35.525 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 35.626 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 35.632 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위는 cann입니다. o 길이가 0입니다. 09-17 16 : 54 : 35.632 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 길이가 0 일 수 없습니다. 09-17 16 : 54 : 36.980 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위에는 길이가 없습니다. 길이가09-17 16 : 54 : 36.980 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 길이가 0 일 수 없음 09-17 16 : 54 : 37.201 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위에는 0을 사용할 수 없습니다 길이 09-17 16 : 54 : 37.201 : E가/SpannableStringBuilder (4926) SPAN_EXCLUSIVE_EXCLUSIVE 스팬는 제로 길이를 가질 수 09-17 16 : 54 : 37.419 : E는/SpannableStringBuilder (4926) SPAN_EXCLUSIVE_EXCLUSIVE 스팬 제로 길이를 가질 수 09-17 16:54:37.419 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 길이가 0 일 수 없음 09-17 16:54:39.064 : E/SpannableStringBuilder (4926) : SPAN_EXCLUSIVE_EXCLUSIVE 범위의 길이가 0이 될 수 없음 09-17 16 : 54 : 39.064 : E는/SpannableStringBuilder (4926)은 54 : 39.835 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 : SPAN_EXCLUSIVE_EXCLUSIVE 스팬 09-17 (16)는 제로 길이를 가질 수 54 : 41.707 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null 09-17 16 : 54 : 45.142 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 null 09-17 16 : 54 : 46.084 : I가/HwSecImmHelper은 (4926)는 : mSecurityInputMethodService가 09-17 16 널 : 54 : 47.246 : I/HwSecImmHelper (4926) : mSecurityInputMethodService가 null입니다. 09-17 16 : 54 : 47.395 : I/art (4926) : System.exit이 호출 됨, 상태 : 0 09-17 16 : 54 : 47.395 : I/AndroidRuntime (4926) : VM이 결과 코드 0으로 종료되고 정리가 스킵되었습니다.

는 당신이 getDrawingCache에 의해 비트 맵에 추가하기 전에 레이아웃에 buildDrawingCache 메소드를 호출하지 않는 것 같다 올바른

답변

0

를 바랍니다.

는 다음과 같이 (이 코드는 당신이 사용하는 다른 옵션없이) 수행

RelativeLayout RTLout= (RelativeLayout)findViewById(R.id.relativeViewPrint); 
RTLout.setDrawingCacheEnabled(true); 
RTLout.buildDrawingCache(); 
Bitmap bm = view.getDrawingCache(); 
+0

감사합니다,하지만 나 작동하지 않습니다. –

+0

프로세스 중에 예외가 발생합니까 아니면 단순히 빈 파일을 저장합니까? – abbath

+0

나는이 메시지 만받습니다 : I/HwSecImmHelper : mSecurityInputMethodService가 null입니다 안드로이드 프로그래밍에 대한 저의 첫 시도입니다 :/ –