Example usage for android.graphics.drawable Drawable setAlpha

List of usage examples for android.graphics.drawable Drawable setAlpha

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable setAlpha.

Prototype

public abstract void setAlpha(@IntRange(from = 0, to = 255) int alpha);

Source Link

Document

Specify an alpha value for the drawable.

Usage

From source file:org.catrobat.catroid.content.bricks.BroadcastWaitBrick.java

@Override
public View getViewWithAlpha(int alphaValue) {
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.brick_broadcast_wait_layout);
    Drawable background = layout.getBackground();
    background.setAlpha(alphaValue);
    this.alphaValue = (alphaValue);
    return view;//from w w  w.  j ava 2 s . co  m
}

From source file:com.eusecom.saminveantory.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_inveantory);

    /* Assinging the toolbar object ot the view
    and setting the the Action bar to our toolbar
     *//*  w  ww  . ja  v  a2 s.co m*/
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);

    View backgroundImage = findViewById(R.id.background);
    Drawable background = backgroundImage.getBackground();
    background.setAlpha(20);

    incomplet = "0";
    String serverx = SettingsActivity.getServerName(this);
    if (serverx != null && !serverx.isEmpty()) {
        // doSomething
    } else {
        serverx = "www.ala.sk/androideshop";
    }

    String delims = "[/]+";
    String[] serverxxx = serverx.split(delims);

    if (serverxxx.length < 2) {
        serverx = "www.ala.sk/androideshop";
        serverxxx = serverx.split(delims);
    }

    //Create Folder
    File folder = new File(
            Environment.getExternalStorageDirectory().toString() + "/eusecom/" + serverxxx[1] + "/inventura");
    if (!folder.exists()) {
        folder.mkdirs();
    }

    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    String TITLES[] = { navMenuTitles[0], navMenuTitles[1], navMenuTitles[2], navMenuTitles[3],
            navMenuTitles[4], navMenuTitles[5] };

    mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView); // Assigning the RecyclerView Object to the xml View

    mRecyclerView.setHasFixedSize(true); // Letting the system know that the list objects are of fixed size
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    mAdapter = new MyAdapter(this, TITLES, ICONS, NAME, EMAIL, PROFILE); // Creating the Adapter of MyAdapter class(which we are going to see in a bit)
    // And passing the titles,icons,header view name, header view email,
    // and header view profile picture
    mRecyclerView.setAdapter(mAdapter); // Setting the adapter to RecyclerView

    Drawer = (DrawerLayout) findViewById(R.id.DrawerLayout); // Drawer object Assigned to the view
    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, toolbar, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // code here will execute once the drawer is opened( As I dont want anything happened whe drawer is
            // open I am not going to put anything here)
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            // Code here will execute once drawer is closed
        }

    }; // Drawer Toggle Object Made
    Drawer.setDrawerListener(mDrawerToggle); // Drawer Listener set to the Drawer toggle
    mDrawerToggle.syncState(); // Finally we set the drawer toggle sync State

    // btn ean control stock
    btnEan = (Button) findViewById(R.id.btnEan);
    btnEan.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Launching All products Activity
            Intent i = new Intent(getApplicationContext(), InventuraSDnewActivity.class);
            startActivity(i);

        }
    });

    // btn ean no stock
    btnEanno = (Button) findViewById(R.id.btnEanno);
    btnEanno.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Launching All products Activity
            Intent i = new Intent(getApplicationContext(), InventuraNOnewActivity.class);
            startActivity(i);

        }
    });

    // btn qrcode
    btnQrcode = (Button) findViewById(R.id.btnQrcode);
    btnQrcode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // Launching All products Activity
            Intent i = new Intent(getApplicationContext(), QrcodeActivity.class);
            startActivity(i);

        }
    });

}

From source file:co.paulburke.android.textviewpager.TextViewPagerIndicator.java

private void setBackgroundAlpha(int alpha) {
    Drawable background = getBackground();
    if (background != null)
        background.setAlpha(alpha);
}

From source file:com.z299studio.pb.TourActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        mCurrent = savedInstanceState.getInt(C.PAGE_NUM, 0);
        mReady = savedInstanceState.getBoolean("ready", false);
        mFromActivity = savedInstanceState.getInt(C.ACTIVITY);
    } else {// w  ww . j  a  v a  2 s.c o  m
        mCurrent = 0;
        mReady = false;
        mFromActivity = getIntent().getExtras().getInt(C.ACTIVITY, C.Activity.SETTINGS);

    }
    setContentView(R.layout.activity_welcome);
    mPager = (ViewPager) findViewById(R.id.pager);
    int ids[] = { R.id.indicator_0, R.id.indicator_1, R.id.indicator_2 };
    mBackground = (LayerDrawable) mPager.getBackground();
    mBackground.getDrawable(0).setAlpha(255);
    mBackground.getDrawable(1).setAlpha(0);
    mBackground.getDrawable(2).setAlpha(0);
    mBackground.getDrawable(3).setAlpha(0);
    for (int i = 0; i < NUM_PAGES; ++i) {
        mIndicators[i] = (ImageView) findViewById(ids[i]);
    }
    mSkip = (Button) findViewById(R.id.skip);
    mNext = (Button) findViewById(R.id.next);
    mContainer = (LinearLayout) findViewById(R.id.container);
    mAppText = (TextView) findViewById(R.id.app);
    if (!mReady) {
        mAppText.animate().alpha(1.0f).setDuration(400).setListener(this);
    } else {
        mPager.setAlpha(1.0f);
        mContainer.setAlpha(1.0f);
    }
    PagerAdapter pagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager());
    mPager.setAdapter(pagerAdapter);
    mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            adjustNavigation(position);
            invalidateOptionsMenu();
        }
    });
    mPager.setPageTransformer(true, new ViewPager.PageTransformer() {
        @Override
        public void transformPage(View view, float position) {
            int index = (Integer) view.getTag();
            Drawable currentDrawableInLayerDrawable;
            currentDrawableInLayerDrawable = mBackground.getDrawable(index);
            if (position <= -1 || position >= 1) {
                currentDrawableInLayerDrawable.setAlpha(0);
            } else if (position == 0) {
                currentDrawableInLayerDrawable.setAlpha(255);
            } else {
                currentDrawableInLayerDrawable.setAlpha((int) (255 - Math.abs(position * 255)));
            }
        }
    });
    if (mCurrent > 0) {
        mPager.setCurrentItem(mCurrent);
    }
}

From source file:org.mariotaku.twidere.util.ThemeUtils.java

public static void setupDrawerBackground(Context context, View view) {
    if (!(context instanceof IThemedActivity))
        return;/*from   www . ja  v a2 s  . c  om*/
    final int themeRes = ((IThemedActivity) context).getCurrentThemeResourceId();
    final int drawerThemeRes = getDrawerThemeResource(themeRes);
    final String backgroundOption = ((IThemedActivity) context).getThemeBackgroundOption();
    final int alpha = ((IThemedActivity) context).getCurrentThemeBackgroundAlpha();
    final Drawable d;
    if (isSolidBackground(backgroundOption)) {
        d = new ColorDrawable(Color.BLACK);
    } else {
        d = getWindowBackgroundFromTheme(context, drawerThemeRes);
    }
    if (d == null)
        throw new NullPointerException();
    if (isTransparentBackground(backgroundOption)) {
        d.setAlpha(alpha);
    }
    ViewSupport.setBackground(view, d);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

private static Drawable applyActionBarDrawable(final Context context, final Drawable d,
        final boolean applyAlpha) {
    if (d == null)
        return null;
    d.mutate();//from  w ww. j  ava 2  s  .c  om
    if (d instanceof LayerDrawable) {
        final Drawable colorLayer = ((LayerDrawable) d).findDrawableByLayerId(R.id.color_layer);
        if (colorLayer != null) {
            final int color = getActionBarColor(context);
            colorLayer.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
        }
    }
    if (applyAlpha) {
        d.setAlpha(getThemeAlpha(context));
    }
    return d;
}

From source file:org.linphone.StatusFragment.java

public void showZRTPDialog(final LinphoneCall call) {
    if (getActivity() == null) {
        Log.w("Can't display ZRTP popup, no Activity");
        return;/*from ww w  .j a  v a 2 s.  co m*/
    }

    if (ZRTPdialog == null || !ZRTPdialog.isShowing()) {
        ZRTPdialog = new Dialog(getActivity());
        ZRTPdialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Drawable d = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.colorC));
        d.setAlpha(200);
        ZRTPdialog.setContentView(R.layout.dialog);
        ZRTPdialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.MATCH_PARENT);
        ZRTPdialog.getWindow().setBackgroundDrawable(d);
        String zrtpToRead, zrtpToListen;

        if (call.getDirection().equals(CallDirection.Incoming)) {
            zrtpToRead = call.getAuthenticationToken().substring(0, 2);
            zrtpToListen = call.getAuthenticationToken().substring(2);
        } else {
            zrtpToListen = call.getAuthenticationToken().substring(0, 2);
            zrtpToRead = call.getAuthenticationToken().substring(2);
        }

        TextView customText = (TextView) ZRTPdialog.findViewById(R.id.customText);
        String newText = getString(R.string.zrtp_dialog1).replace("%s", zrtpToRead)
                + getString(R.string.zrtp_dialog2).replace("%s", zrtpToListen);
        customText.setText(newText);
        Button delete = (Button) ZRTPdialog.findViewById(R.id.delete_button);
        delete.setText(R.string.accept);
        Button cancel = (Button) ZRTPdialog.findViewById(R.id.cancel);
        cancel.setText(R.string.deny);

        delete.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                call.setAuthenticationTokenVerified(true);
                if (encryption != null) {
                    encryption.setImageResource(R.drawable.security_ok);
                }
                ZRTPdialog.dismiss();
            }
        });

        cancel.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (call != null) {
                    call.setAuthenticationTokenVerified(false);
                    if (encryption != null) {
                        encryption.setImageResource(R.drawable.security_ko);
                    }
                }
                ZRTPdialog.dismiss();
            }
        });
        ZRTPdialog.show();
    }
}

From source file:com.sutromedia.android.core.PhotoActivity.java

public void onSetupView(View view, int viewId) {
    final IPhoto photo = getCurrentPhoto();
    if (photo != null) {

        int backgroundId = (viewId == R.layout.image_view_inside) ? R.drawable.attrib_inside
                : R.drawable.attrib_outside;

        Drawable background = getResources().getDrawable(backgroundId);
        background.setAlpha(155);
        view.findViewById(R.image.licenseGroup).setBackgroundDrawable(background);
        setVisibility(view, R.image.caption, !mInSlideShow && !isSubsetOnEntry());
        TextView caption = (TextView) view.findViewById(R.image.caption);
        String entryName = photo.getEntryName();
        if (entryName != null) {
            entryName = entryName.replace(' ', '\u00A0');
            entryName += "\u00A0\u00A0\u25B6";
        }/*from  ww  w. jav  a  2s  .  c  o m*/
        caption.setText(entryName);
        caption.setSingleLine(true);
        caption.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                onReceiveEntry(new NavigationDetailWeb(photo.getEntryId()));
            }
        });

        setVisibility(view, R.image.licenseGroup, !mInSlideShow);
        Integer[] icons = PhotoLicence.getIcons(photo);
        setImageView(view, R.image.license1, 0, icons);
        setImageView(view, R.image.license2, 1, icons);
        TextView owner = (TextView) view.findViewById(R.image.owner);
        if (icons.length > 0) {
            owner.setText(photo.getAuthor());
        } else {
            view.findViewById(R.image.licenseGroup).setVisibility(View.GONE);
        }

        String url = photo.getUrl();
        View licenceGroup = view.findViewById(R.image.licenseGroup);
        if (url != null && url.length() > 0) {
            owner.setTextColor(Color.rgb(0x19, 0x49, 0x90));
            owner.setTypeface(null, Typeface.BOLD);

            licenceGroup.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    onReceiveEntry(new NavigationWeb(photo.getUrl()));
                }
            });
        } else {
            owner.setTypeface(null, Typeface.NORMAL);
            owner.setTextColor(Color.WHITE);
            licenceGroup.setOnClickListener(null);
        }

        setupTouchOnPlayButton();
        setVisibility(R.image.play_slideshow, !mInSlideShow && mShowSlideShowControls);
        setVisibility(R.image.loading, mMissingPhoto);
        setVisibility(R.image.wait, mMissingPhoto && isOnline());

        String missingTextTemplate = getString(
                mMissingPhoto && isOnline() ? R.string.missing_photo : R.string.missing_not_online);
        String missingText = String.format(missingTextTemplate, mCurrentImage + 1, getImageCountInSet());

        setText(R.image.missing, missingText);
    }
}

From source file:website.openeng.anki.Reviewer.java

@SuppressLint("NewApi")
@Override/*w  ww.j  a va 2s  . c  om*/
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.reviewer, menu);
    Resources res = getResources();
    if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note)
                .setIcon(R.drawable.ic_star_white_24dp);
    } else {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note)
                .setIcon(R.drawable.ic_star_outline_white_24dp);
    }
    if (colIsOpen() && getCol().undoAvailable()) {
        menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT);
    } else {
        menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT);
    }
    if (mPrefWhiteboard) {
        // Don't force showing mark icon when whiteboard enabled
        // TODO: allow user to customize which icons are force-shown
        MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard"
        if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) {
            // Android 4.x device with overflow menu in the action bar and small screen can't
            // support forcing 2 extra items into the action bar
            Display display = getWindowManager().getDefaultDisplay();
            DisplayMetrics outMetrics = new DisplayMetrics();
            display.getMetrics(outMetrics);
            float density = getResources().getDisplayMetrics().density;
            float dpWidth = outMetrics.widthPixels / density;
            if (dpWidth < 360) {
                menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }
        }
        // Configure the whiteboard related items in the action bar
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard);
        menu.findItem(R.id.action_hide_whiteboard).setVisible(true);
        menu.findItem(R.id.action_clear_whiteboard).setVisible(true);

        Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp);
        if (mShowWhiteboard) {
            whiteboardIcon.setAlpha(255);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard);
        } else {
            whiteboardIcon.setAlpha(77);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard);
        }
    } else {
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard);
    }
    if (!CompatHelper.isHoneycomb() && !mDisableClipboard) {
        menu.findItem(R.id.action_search_dictionary).setVisible(true)
                .setEnabled(!(mPrefWhiteboard && mShowWhiteboard))
                .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle()
                        : res.getString(R.string.menu_select));
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.ichi2.anki.Reviewer.java

@SuppressLint("NewApi")
@Override/*w  w w .j  a  v a  2 s  .co  m*/
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.reviewer, menu);
    Resources res = getResources();
    if (mCurrentCard != null && mCurrentCard.note().hasTag("marked")) {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_unmark_note)
                .setIcon(R.drawable.ic_star_white_24dp);
    } else {
        menu.findItem(R.id.action_mark_card).setTitle(R.string.menu_mark_note)
                .setIcon(R.drawable.ic_star_outline_white_24dp);
    }
    if (colIsOpen() && getCol().undoAvailable()) {
        menu.findItem(R.id.action_undo).setEnabled(true).getIcon().setAlpha(Themes.ALPHA_ICON_ENABLED_LIGHT);
    } else {
        menu.findItem(R.id.action_undo).setEnabled(false).getIcon().setAlpha(Themes.ALPHA_ICON_DISABLED_LIGHT);
    }
    if (mPrefWhiteboard) {
        // Don't force showing mark icon when whiteboard enabled
        // TODO: allow user to customize which icons are force-shown
        MenuItemCompat.setShowAsAction(menu.findItem(R.id.action_mark_card),
                MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
        // Check if we can forceably squeeze in 3 items into the action bar, if not hide "show whiteboard"
        if (CompatHelper.getSdkVersion() >= 14 && !ViewConfiguration.get(this).hasPermanentMenuKey()) {
            // Android 4.x device with overflow menu in the action bar and small screen can't
            // support forcing 2 extra items into the action bar
            Display display = getWindowManager().getDefaultDisplay();
            DisplayMetrics outMetrics = new DisplayMetrics();
            display.getMetrics(outMetrics);
            float density = getResources().getDisplayMetrics().density;
            float dpWidth = outMetrics.widthPixels / density;
            if (dpWidth < 360) {
                menu.findItem(R.id.action_hide_whiteboard).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
            }
        }
        // Configure the whiteboard related items in the action bar
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.disable_whiteboard);
        menu.findItem(R.id.action_hide_whiteboard).setVisible(true);
        menu.findItem(R.id.action_clear_whiteboard).setVisible(true);

        Drawable whiteboardIcon = getResources().getDrawable(R.drawable.ic_gesture_white_24dp);
        if (mShowWhiteboard) {
            whiteboardIcon.setAlpha(255);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.hide_whiteboard);
        } else {
            whiteboardIcon.setAlpha(77);
            menu.findItem(R.id.action_hide_whiteboard).setIcon(whiteboardIcon);
            menu.findItem(R.id.action_hide_whiteboard).setTitle(R.string.show_whiteboard);
        }
    } else {
        menu.findItem(R.id.action_enable_whiteboard).setTitle(R.string.enable_whiteboard);
    }
    if (!CompatHelper.isHoneycomb() && !mDisableClipboard) {
        menu.findItem(R.id.action_search_dictionary).setVisible(true)
                .setEnabled(!(mPrefWhiteboard && mShowWhiteboard))
                .setTitle(clipboardHasText() ? Lookup.getSearchStringTitle()
                        : res.getString(R.string.menu_select));
    }
    if (getCol().getDecks().isDyn(getParentDid())) {
        menu.findItem(R.id.action_open_deck_options).setVisible(false);
    }
    return super.onCreateOptionsMenu(menu);
}