0
A
回答
0
試試這個代碼。
//得到今天的一天。並放入位於右下角的ListView中//在xml文件中。
final Calendar cal = Calendar.getInstance();
year = cal.get(Calendar.YEAR);
month = cal.get(Calendar.MONTH)+1;
day = cal.get(Calendar.DAY_OF_MONTH);
TextView out=(TextView)findViewById(R.id.yourtextview);
out.setText(day+"."+month+"."+year);
0
試試這個
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
public class WatermarkImage {
public static void main(String[] args) {
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date now = new Date();
File origFile = new File("E:/watermark/test.jpg");
ImageIcon icon = new ImageIcon(origFile.getPath());
// create BufferedImage object of same width and height as of original image
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(),
icon.getIconHeight(), BufferedImage.TYPE_INT_RGB);
// create graphics object and add original image to it
Graphics graphics = bufferedImage.getGraphics();
graphics.drawImage(icon.getImage(), 0, 0, null);
// set font for the watermark text
graphics.setFont(new Font("Arial", Font.BOLD, 20));
String watermark = sdfDate.format(now);
// add the watermark text
graphics.drawString(watermark, (icon.getIconWidth()*80)/100, (icon.getIconHeight()*90)/100);
graphics.dispose();
File newFile = new File("E:/watermark/WatermarkedImage.jpg");
try {
ImageIO.write(bufferedImage, "jpg", newFile);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(newFile.getPath() + " created successfully!");
}
}
相關問題
- 1. 如何通過CSS將圖標添加到textareas的右下角?
- 2. 在圖像上添加多行文本並將其保存
- 3. 將圖像粘貼到右下角
- 4. jquery如何將圖釘添加到圖像並將位置保存到SQL
- 5. 如何保存圖像添加文本後爲圖像
- 6. 將文字添加到圖像並保存
- 7. 如何將背景圖像添加到活動並將其對齊到右下角?
- 8. 將文本添加到圖像而不保存
- 9. 如何將圖像水印添加到右下角的文字環繞圖像上?
- 10. 德爾福:如何添加文字到圖像並保存新圖像?
- 11. 將字符串添加到位圖圖像並保存vb
- 12. 將空格添加到圖像並將文件保存到服務器
- 13. 如何將圖像保存到Mysql數據庫中並按日期分開?
- 14. 如何將保存的圖像添加到mediastore並生成縮略圖?
- 15. 添加並保存圖像的文本描述
- 16. 如何將框架添加到iOS中的圖像並保存到庫
- 17. 將UIVIew添加爲子視圖到窗口的右下角iPhone
- 18. 動態地將視圖添加到右下角
- 19. javascript懸停圖像並顯示左上角到右下角
- 20. CSS如何定位圖像右下角
- 21. 如何從網絡加載圖像並將圖像保存到獨立存儲?
- 22. 如何將圖像從Amazon S3下載並保存到圖像視圖
- 23. 用日文文本保存圖像
- 24. 如何將當前日期和時間添加到保存文件的名稱?
- 25. 如何將緩存控制過期標頭添加到圖像?
- 26. 如何將日期保存到oracle
- 27. 將日期添加到日期並計算結束日期?
- 28. 將圖像保存並加載到IsolatedStorage需要保存兩次
- 29. 如何添加文本或合併圖像到JPEG文件
- 30. 如何將文字添加到圖像
嗨ERAY,歡迎SO。我們不是一個編碼編寫服務,像「我想爲X編寫代碼」這樣的問題不會得到回答。請向我們展示您嘗試解決此問題的努力(例如您編寫的代碼),描述您獲得的錯誤/問題,並且我們將盡力幫助您解決這些問題。 –