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 4084162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:24:16+00:00 2026-05-20T18:24:16+00:00

Okay, so I’ve done some looking around and I see how you are SUPPOSED

  • 0

Okay, so I’ve done some looking around and I see how you are SUPPOSED to do it, but for me, it is just not working.

I need to be able to set the alpha of a RelativeLayout both in XML and in code. For my XML, I have the following

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/player_controls"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:alpha="0.0">
    <RelativeLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id="@+id/player_controls_touch_me"
        >
        </RelativeLayout>
</RelativeLayout>

I get the error: no resource identifier found for attribute 'alpha' in package 'android'

Also, based on the Android documentation, I should be able to call setAlpha(double) on any View object, but when I try to make that call on a RelativeLayout it tells me that this method is not defined for this object.

Why am I not able to control the alpha transparency for a RelativeLayout object in Android? Am i missing something? Thanks!

Update

Although using the visibility property works, it prevents me from be able to click on the ViewGroup. This is important for me because I am utilizing the OnTouchListener of the ViewGroup.

What I am trying to do is to have a layer with media controls, initially hidden. when the user taps anywere on the screen, I want the controls to fade in and when they tap the screen again I want the controls to fade out. I have this part already working. I am using a viewgroup that sits over-top my entire application with an OnTouchListener attached that can determine if it has or hasn’t been touched. My problem is that after the animation runs to fade out the controls, they re-appear. If I use @Hydrangea suggestion, I can have it fade out and immediately made invisible. This gives me the desired effect, but then the ViewGroup is unclickable and the user cannot get the controls to come back (or go away, depending on what we decide to do first).

I hope this makes sense.

  • 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-05-20T18:24:17+00:00Added an answer on May 20, 2026 at 6:24 pm

    You’ll want to use a alpha animation to fade things in and out. This will maintain your touch events for your layouts. Here’s an example

    public class Main extends Activity {
    /** Called when the activity is first created. */
    
    private boolean mShowing = false;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        findViewById(R.id.textview).setOnClickListener(new OnClickListener(){
    
            @Override
            public void onClick(View arg0) {
                if(mShowing){
                Animation animation = new AlphaAnimation(1.0f, 0.0f);
                animation.setFillAfter(true);
                arg0.startAnimation(animation);
                } else {
                    Animation animation = new AlphaAnimation(0.0f, 1.0f);
                    animation.setFillAfter(true);
                    arg0.startAnimation(animation);
                }
    
                mShowing = !mShowing;
            }
    
        });
    }
    

    }

    Here’s the accompanying xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <TextView  
        android:id="@+id/textview"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        android:clickable="true"
        />
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so im working on this php image upload system but for some reason
Okay, this is probably a very basic question; but, I'm just getting back in
Okay i need to turn a string to a float do some math then
Okay, so the answer to my question might not be the problem but here's
Okay I am having some problems with being able to change bitmaps when a
Okay, I am using a custom tab bar (not a tab based app) but
Okay, I have setup up a handler for a div click but for some
Okay, I kinda asked this question already, but noticed that i might have not
Okay, so this probably sounds terribly nefarious, but I need such capabilities for my
Okay, so I know that using eval() isn't great, but I haven't been able

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.