Create a Bitmap/Drawable from file path

Create bitmap from file path: File sd = Environment.getExternalStorageDirectory(); File image = new File(sd+filePath, imageName); BitmapFactory.Options bmOptions = new BitmapFactory.Options(); Bitmap bitmap = BitmapFactory.decodeFile(image.getAbsolutePath(),bmOptions); bitmap = Bitmap.createScaledBitmap(bitmap,parent.getWidth(),parent.getHeight(),true); imageView.setImageBitmap(bitmap); If you want to scale the bitmap to the parent’s height and width then use Bitmap.createScaledBitmap function. I think you are giving the wrong file path. 🙂 … Read more

Android Background Drawable Not Working in Button Since Android Studio 4.1

The Android Studio 4.1 new-project wizard, for many of its templates, has the project use the Material Components for Android library. And, it sets up the default theme to be based on Theme.MaterialComponents.DayNight.DarkActionBar. A side effect of this is that any <Button> elements in a layout get turned into MaterialButton widgets, not regular Button widgets. … Read more

PhoneGap Android: How to force Application to use icons from asset\www\res instead res\drawable folder?

config.xml is used only by the PhoneGap Build service. – Building locally, this file is ignored and the files in your res/drawable directory are used. – Building with PGBuild, the service looks for this file at the root of your project (next to index.html) and uses it to identify what images should be copied into … Read more

Android shape border with gradient

try something like this: <?xml version=”1.0″ encoding=”UTF-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android” > <item> <shape android:shape=”rectangle” > <gradient android:angle=”360″ android:centerColor=”#e95a22″ android:endColor=”#ff00b5″ android:gradientRadius=”360″ android:startColor=”#006386″ android:type=”sweep” /> <stroke android:width=”2dp” android:color=”#ff207d94″ /> </shape> </item> <item android:bottom=”2dp” android:left=”2dp” android:right=”2dp” android:top=”2dp”> <shape android:shape=”rectangle” > <solid android:color=”#fff” /> </shape> </item> </layer-list>

How to upload an image in parse server using parse api in android

After struggling for several hours here is code segment works for me. 1. Data Member of activity class Bitmap bmp; Intent i; Uri BmpFileName = null; 2. Starting the camera. Goal is to start camera activity and BmpFileName to store the referrence to file String storageState = Environment.getExternalStorageState(); if (storageState.equals(Environment.MEDIA_MOUNTED)) { String path = Environment.getExternalStorageDirectory().getName() … Read more

Open-sided Android stroke?

I achieved a good solution with this one: <?xml version=”1.0″ encoding=”utf-8″?> <layer-list xmlns:android=”http://schemas.android.com/apk/res/android”> <!– This is the line –> <item android:top=”-1dp” android:right=”-1dp” android:left=”-1dp”> <shape> <solid android:color=”@android:color/transparent” /> <stroke android:width=”1dp” android:color=”#ffffff” /> </shape> </item> </layer-list> This works well in case you need a transparent background but still an open stroke color (In my case I only … Read more