4 Replies - 178 Views - Last Post: 09 November 2018 - 07:48 AM

#1 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 159
  • Joined: 15-January 13

Trying to make an image darker with rgba.

Posted 02 November 2018 - 07:08 AM

Hi!

I have this main layout and I want to load and image(throught activity) and set it as background. But I want it a little bit darker. To do that i'm using two imageviews filling all the screen. The first one will be the background imageview and the second one will be a "layer" with some transparency to give the background image a darker effect.

But the problem is I don't know how to set a rgba background color and I can't find on Google. I find how to do that by coding but I think there is a simpler solution.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    android:id="@+id/main_layout"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- Background image. Using "scr" just to test. -->
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/pulse"/>

    <!-- Transparency layer but I dont know how to set rgba background color. -->
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#000000"/>

    <!-- Buttons, TextViews... will be here. -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"></LinearLayout>
</RelativeLayout>


Is This A Good Question/Topic? 0
  • +

Replies To: Trying to make an image darker with rgba.

#2 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 159
  • Joined: 15-January 13

Re: Trying to make an image darker with rgba.

Posted 02 November 2018 - 12:54 PM

I found a solution for that. Actually I was almost there. I was trying #RRGGBBAA.

The correct format for rgba is #AARRGGBB.
android:background="#CC000000"


I don't know if I need to create other thread for that but could you people suggest me how to do that but for blur an image?
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14856
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: Trying to make an image darker with rgba.

Posted 02 November 2018 - 01:05 PM

There seems to be a few tutorials on that.

"android blur effect"

https://www.androidp...fect-on-android
Was This Post Helpful? 0
  • +
  • -

#4 robgeek   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 159
  • Joined: 15-January 13

Re: Trying to make an image darker with rgba.

Posted 02 November 2018 - 02:04 PM

The idea was doing that directly on xml file like transparency. I don't know if is possible.
Was This Post Helpful? 0
  • +
  • -

#5 EndLessMind   User is offline

  • Android Expert
  • member icon

Reputation: 273
  • View blog
  • Posts: 1,252
  • Joined: 13-March 09

Re: Trying to make an image darker with rgba.

Posted 09 November 2018 - 07:48 AM

I think you want background with tint:

<RelativeLayout
...
    android:background="@drawable/pulse"
    android:backgroundTint="#CC000000"
    android:backgroundTintMode="muliply" />


This post has been edited by EndLessMind: 09 November 2018 - 07:49 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1