2016-06-28 66 views
0

我必須製作如附圖所示的可打印名片並以.png圖像的形式附加到電子郵件中。我不知道我將如何使android的這個形象,將其固定以.png格式製作卡片圖像並將其附加到電子郵件中android

enters the image description here

到電子郵件上的按鈕click.For您參考。我已該卡的圖像在這裏。謝謝你看我的帖子..

+0

我不知道我將如何使這一形象通過程序..如果你有任何想法的軟件建議 –

+0

你從服務器或靜態數據獲取數據 – Nitesh

+0

我會得到差異。數據根據來自服務器的差異用戶 –

回答

1

嘗試下面的代碼,你可以做到這一點

File filePath = new File("/path/file.png"); 
Uri uri = Uri.fromFile(filePath); 
Intent intent = new Intent(Intent.ACTION_SEND); 
intent.setType("image/png"); 
intent.putExtra(Intent.EXTRA_STREAM, uri); 
startActivity(Intent.createChooser(intent,"Email:")); 
+0

這件事我知道..我的要求是使這個圖像動態和填充程序的所有細節像用戶圖像,用戶名等。 –

+0

@TulikaKansal簡單,以設備截圖的方式編程分享按鈕,然後使用上面的代碼共享相同。 http://stackoverflow.com/questions/2661536/how-to-programmatically-take-a-screenshot-in-android – Ajit

+0

我的佈局是圖像不附加到任何活動,也我需要設備無關的圖像我的意思是固定的高度和寬度像遊覽卡。我怎樣才能做到這一點?\ –

2

的一種方法是使該卡成爲一個佈局,然後填寫,或讓用戶填寫它(取)。然後你就可以使用下面的代碼打開視圖成位圖

public Bitmap viewToBitmap(View view) { 
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(bitmap); 
    view.draw(canvas); 
    return bitmap; 
} 

代碼是從這裏這個問題,

Convert frame layout into image and save it

相關問題