-2

Is There any solution to set image darkly?

<LinearLayout
            android:background="@drawable/terminalImage"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

I wrote like this, so I can't use background anymore. Is there any option or solution to set background image darkly?

SunSpike
  • 31
  • 5

2 Answers2

0

Add backgdround tint which will add color upon the Existing background.

android:backgroundTint="@android:color/background_dark"
Sharath kumar
  • 4,064
  • 1
  • 14
  • 20
0

You can Add Gradient on Image . Check this Post[How to put black transparent on image in android

Or You can try this post . Alpha-gradient on Android

you can check the opacity from here. How to make a background 20% transparent on Android

For do it Programmaitcally

private Bitmap darkenBitMap(Bitmap bm) {

    Canvas canvas = new Canvas(bm);
    Paint p = new Paint(Color.RED);
    //ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x00222222); // lighten
    ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);    // darken
    p.setColorFilter(filter);
    canvas.drawBitmap(bm, new Matrix(), p);

    return bm;
}
Thientvse
  • 1,753
  • 1
  • 14
  • 23
Sardar Khan
  • 845
  • 6
  • 16