Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8153605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:04:24+00:00 2026-06-06T16:04:24+00:00

I am using an image as the background of a linear layout in my

  • 0

I am using an image as the background of a linear layout in my android program.I need to set opacity for this.Can anyone tell me how can I do this?..The image that is translucent doesnt show the opacity,doesn’t know the reason though.
Thanks in advance for your valuable comments

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:04:25+00:00Added an answer on June 6, 2026 at 4:04 pm

    If you set the background of the LinearLayout programatically this shouldn’t be any problem.

    What you are looking for is the Drawable.setAlpha(int alpha) method. From a personal project:

    ImageView image = (ImageView) row.findViewById(R.id.list_icon);
    image.setImageResource(R.id.something);
    image.setAlpha(110);
    

    Not exacly the same, but maybe you get the point.

    You are using a drawable as the background of your layout. The challenge here is to get the variable representing your drawable. This is done here:

    In the activity to the layout:

    Resources res = getResources();
    Drawable background = res.getDrawable(R.drawable.*the id*);
        // The layout which are to have the background:
    LinearLayout layout = ((LinearLayout) findViewById(R.id.*you get it*));
        // Now that we have the layout and the background, we ajust the opacity 
        // of the background, and sets it as the background for the layout
    background.setAlpha( *a number* );
    layout.setBackgroundDrawable(background);
    

    And it should work. At least it did work for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set the background image of canvas using canvas.setBackgroundImage(image); How can i
This is the layout I am using: <ScrollView xmlns:android=http://schemas.android.com/apk/res/android android:background=@color/background android:layout_width=fill_parent android:layout_height=fill_parent android:padding=30dip >
I have a logo link that's using a background-image (css sprite). All works fine,
I have an icon that is inserted into a page using the background-image property.
I'm using such layout: <LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:background=@drawable/logo android:orientation=horizontal > The drawable/logo.xml : <bitmap
I am using this layout for my screen: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
I want to set a background image to my listview so that regardless of
In my android app i have got an activity that uses a linear layout
I have given a table background image using css background-image property. The cells are
Is it possible to have transparent background image using CSS3? background: url(../img/bg_paperlines.jpg) repeat-x; Using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.