I have just started to use Bitmap
and want to try design something this button:
I am using SpannableString
for further process. How can I get this type of shape with rounded corner with Bitmap
?
I have just started to use Bitmap
and want to try design something this button:
I am using SpannableString
for further process. How can I get this type of shape with rounded corner with Bitmap
?
Try this,
Bitmap usage in activity
package com.example.testproject;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.ImageView;
public class TestImages extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView image = (ImageView) findViewById(R.id.test_image);
Bitmap bMap = BitmapFactory.decodeFile("/sdcard/test2.png");
image.setImageBitmap(bMap);
}
}
For rounded image, try the below code
rounded_corner.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- view background color -->
<solid android:color="#ffffff" >
</solid>
<!-- view border color and width -->
<stroke
android:width="1dp"
android:color="#1c1b20" >
</stroke>
<!-- If you want to add some padding -->
<padding
android:bottom="4dp"
android:left="4dp"
android:right="4dp"
android:top="4dp" >
</padding>
<!-- Here is the corner radius -->
<corners android:radius="10dp" >
</corners>
</shape>
Add this file to your drawable folder
main_activity.xml
Add this line to your textview in XML
android:background="@drawable/rounded_corner"