Skip to content

Instantly share code, notes, and snippets.

View ggface's full-sized avatar
🏠
Working from home

Ivan Novikov ggface

🏠
Working from home
View GitHub Profile
@ggface
ggface / README.md
Created January 26, 2021 19:18 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

public static void executeMultipartPost(String url, String imgPath, String field1, String field2){
try {
HttpClient client = new DefaultHttpClient();
HttpPost poster = new HttpPost(url);
File image = new File(imgPath); //get the actual file from the device
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entity.addPart("field1", new StringBody(field1));
entity.addPart("field2", new StringBody(field2));
entity.addPart("image", new FileBody(image));
// formatting numbers
// => "1.2"
String.format("%s", new DecimalFormat("#.##").format(1.2))
// => "1.20"
String.format("%.2f", 1.2)