2015-04-08 2 views
1

J'ai fait une démo pour film-bande, android. Je lie des images à mon runtime LinearLayout, Maintenant je veux enregistrer ensemble, Scrollable View à un bitmap, j'ai essayé beaucoup mais tous donne la solution pour enregistrer seulement l'écran visible en cours au bitmap, quelqu'un peut m'aider s'il vous plaît comment enregistrer scrollable entier Voir (non visible à l'écran) dans un bitmap, mon code est comme ci-dessous:comment créer bitmap de scollview d'images dans Android?

xml

<HorizontalScrollView 
    android:id="@+id/horizontal_scroll_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="55dp" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="55dp" 
    android:scrollbars="none" > 

    <ScrollView 
     android:id="@+id/scroler" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:fillViewport="true" 
     android:scrollbars="none" > 

     <LinearLayout 
      android:id="@+id/mygallery" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" /> 
    </ScrollView> 
</HorizontalScrollView> 

java

View insertPhoto(int i) { 
    LinearLayout layout = new LinearLayout(getApplicationContext()); 
    layout.setLayoutParams(new LayoutParams(252, 252)); 
    layout.setGravity(Gravity.FILL); 

    final ImageView imageView = new ImageView(getApplicationContext()); 
    imageView1 = new ImageView(getApplicationContext()); 
    imageView.setLayoutParams(new LayoutParams(250, 250)); 
    imageView.setScaleType(ImageView.ScaleType.FIT_XY); 

    imageLoader.displayImage("file://" + dataT.get(i).sdcardPath, 
      imageView, new SimpleImageLoadingListener() { 

       public void onLoadingStarted(String imageUri, View view) { 
        imageView.setImageResource(R.drawable.no_media); 
        super.onLoadingStarted(imageUri, view); 
       } 
      }); 
    layout.addView(imageView); 
    return layout; 
} 

utilisant J'ai filmé cette bande en orientation verticale. Et maintenant je veux un bitmap de ce film-strip pour le sauvegarder.

+0

Pourriez-vous élaborer votre question? Que voulez-vous dire exactement par "bitmap of all view"? – Logain

+0

c'est fait !!!!! ... –

Répondre

2
public static Bitmap loadBitmapFromView(View v) { 
     Bitmap b = null; 
      v.measure(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
      b = Bitmap.createBitmap(v.getMeasuredWidth(), 
        v.getMeasuredHeight(), Bitmap.Config.ARGB_8888); 
      Canvas c = new Canvas(b); 
      v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight()); 
      v.draw(c); 
     saveImageToInternalStorage(b); 
     return b; 
    }