Java Code Examples for android.widget.ImageView.setAlpha()

The following are Jave code examples for showing how to use setAlpha() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: SwipeSectorLayout   File: CustomTransformer.java   View Source Code Vote up 7 votes
@Override
public void transformPage(View view, float position) {

    int pageWidth = view.getWidth();
    ImageView imgView = (ImageView)view.findViewById(R.id.img);
    if (position < -1) { // [-Infinity,-1)
        // This page is way off-screen to the left.
    } else if (position <= 0) { // [-1,0]

        view.setAlpha((1 - MIN_ALPHA) * (1 - Math.abs(position)) + MIN_ALPHA);
        float transX = pageWidth * -position;
        view.setTranslationX(transX);
        float scale = (DEFAULT_SCALE - 1.0f) * (1 - Math.abs(position)) + 1;
        imgView.setScaleX(scale);
        imgView.setScaleY(scale);

    } else if (position <= 1) { // (0,1]
        imgView.setAlpha(1.0f);
        imgView.setScaleX(DEFAULT_SCALE);
        imgView.setScaleY(DEFAULT_SCALE);

    } else { // (1,+Infinity]
        // This page is way off-screen to the right.
    }
}
 
Example 2
Project: newIPlay   File: ImageLoader.java   View Source Code Vote up 6 votes
public static void loadImage(Context context, String url, ImageView imageView) {
    // 夜间模式的处理
    if (SPUtil.getBoolean(Constants.IS_NIGHT_MODE)) {
        imageView.setAlpha(0.2f);
        imageView.setBackgroundColor(Color.BLACK);
    }
    Glide.with(context).load(url).into(imageView);
}
 
Example 3
Project: apps_small   File: MainActivity.java   View Source Code Vote up 6 votes
public void doubleTrouble (View myView){

        /* Now we will have one image slide off the screen
        * and another image slide into it's place. Note that one
        * of the images is offscreen in the on create methode below.
        */
        // Define the image views to use.
        ImageView firstPic = (ImageView) findViewById(R.id.imageView2);
        ImageView secondPic = (ImageView) findViewById(R.id.imageView3);
        // Set the alpha (not really needed here, was used in other exercises.
        // Used here to make them "dimmer" at half brightness.
        firstPic.setAlpha(0.5f);
        secondPic.setAlpha(0.5f);
        // Call the translation (movement) and set the duration.
        firstPic.animate().translationXBy(-1000f).setDuration(1500);
        secondPic.animate().translationXBy(-1000f).setDuration(1500);
    }
 
Example 4
Project: civify-app   File: AwardDetailsFragment.java   View Source Code Vote up 6 votes
private void changeTypeButton(Button button, int type) {
    ImageView coins = (ImageView) mViewDetails.findViewById(R.id
            .reward_coins_icon);
    switch (type) {
        case ENABLE_BUTTON:
            coins.setAlpha(1);
            button.setAlpha(1);
            button.setEnabled(true);
            break;
        case DISABLE_BUTTON:
            coins.setAlpha(ALPHA);
            button.setAlpha(ALPHA);
            button.setEnabled(false);
            break;
        default:
            break;
    }
}
 
Example 5
Project: aos-Video   File: DelayedBackgroundLoader.java   View Source Code Vote up 6 votes
@Override
public void setResult(ImageView imageView, LoadTaskItem taskItem) {
    if (DBG) Log.d(TAG, "setResult");
    boolean animate = true;
    if (taskItem.loadObject instanceof ScraperImage) {
        ScraperImage image = (ScraperImage) taskItem.loadObject;
        String file = image.getLargeFile();
        if (file != null && file.equals(lastLoaded)) {
            //!!!animate = false;
            if (DBG) Log.d(TAG, "setResult animate false");
        }
        lastLoaded = file;
    }

    imageView.setImageBitmap(taskItem.result.bitmap);
    if (animate) {
        Log.d(TAG, "   animate backdrop alpha "+mBackgroundAlpha);
        imageView.animate().alpha(mBackgroundAlpha).setDuration(600);
    }
    else {
        Log.d(TAG, "   set backdrop alpha"+mBackgroundAlpha);
        imageView.setAlpha(mBackgroundAlpha);
    }
}
 
Example 6
Project: OpenLibre   File: DataPlotFragment.java   View Source Code Vote up 6 votes
private void updateScanData(List<GlucoseData> trend) {
    if (trend.size() == 0) {
        Toast.makeText(this.getContext(), "No current data available!", Toast.LENGTH_LONG).show();
        return;
    }

    mDataPlotView.findViewById(R.id.scan_data).setVisibility(View.VISIBLE);

    GlucoseData currentGlucose = trend.get(trend.size() - 1);
    TextView tv_currentGlucose = (TextView) mDataPlotView.findViewById(R.id.tv_glucose_current_value);
    tv_currentGlucose.setText(
            String.format(getResources().getString(R.string.glucose_current_value),
            currentGlucose.glucoseString(),
            getDisplayUnit())
    );

    PredictionData predictedGlucose = new PredictionData(trend);

    TextView tv_predictedGlucose = (TextView) mDataPlotView.findViewById(R.id.tv_glucose_prediction);
    tv_predictedGlucose.setText(String.valueOf(predictedGlucose.glucoseData.glucoseString()));
    tv_predictedGlucose.setAlpha((float) min(1, 0.1 + predictedGlucose.confidence()));

    ImageView iv_unit = (ImageView) mDataPlotView.findViewById(R.id.iv_unit);
    if (GLUCOSE_UNIT_IS_MMOL) {
        iv_unit.setImageResource(R.drawable.ic_unit_mmoll);
    } else {
        iv_unit.setImageResource(R.drawable.ic_unit_mgdl);
    }
    iv_unit.setAlpha((float) min(1, 0.1 + predictedGlucose.confidence()));

    ImageView iv_predictionArrow = (ImageView) mDataPlotView.findViewById(R.id.iv_glucose_prediction);

    // rotate trend arrow according to glucose prediction slope
    float rotationDegrees = -90f * max(-1f, min(1f, (float) (predictedGlucose.glucoseSlopeRaw / TREND_UP_DOWN_LIMIT)));
    iv_predictionArrow.setRotation(rotationDegrees);

    // reduce trend arrow visibility according to prediction confidence
    iv_predictionArrow.setAlpha((float) min(1, 0.1 + predictedGlucose.confidence()));
}
 
Example 7
Project: shortrain   File: TrainActionActivity.java   View Source Code Vote up 6 votes
private void addTrainToScreen(Rect trainRect) {
    rootView = new FrameLayout(this);
    engineView = addTrain(trainRect, TrainView.ENGINE, rootView);
    for (int i = 0; i < NUMBER_OF_CARS; i++) {
        carsView.add(addTrain(trainRect, TrainView.CAR, rootView));
    }

    rootView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fadeOutActivity();
        }
    });

    float iconToWidthFactor = 0.34f;
    ImageView startRoof = new ImageView(this);
    startRoof.setImageResource(R.drawable.long_start_point_roof);
    int trainRectSize = (int) (trainRect.width() * (1f - iconToWidthFactor));
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(trainRectSize, trainRectSize);
    startRoof.setX(trainRect.left + trainRect.width() * iconToWidthFactor / 2 - 15);
    startRoof.setY(trainRect.top + trainRect.width() * iconToWidthFactor / 2);
    rootView.addView(startRoof, lp);

    startRoof.setAlpha(0f);
    startRoof.animate()
            .alpha(1f)
            .setInterpolator(new DecelerateInterpolator())
            .setDuration(500)
            .start();

    setContentView(rootView);
}
 
Example 8
Project: FireFiles   File: IconHelper.java   View Source Code Vote up 6 votes
/**
 * Load thumbnails for a directory list item.
 * @param uri The URI for the file being represented.
 * @param mimeType The mime type of the file being represented.
 * @param docFlags Flags for the file being represented.
 * @param iconThumb The itemview's thumbnail icon.
 * @param iconMimeBackground
 * @return
 */
public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon,
                          ImageView iconMime, ImageView iconThumb, View iconMimeBackground) {
    boolean cacheHit = false;

    final String docAuthority = uri.getAuthority();
    String docId = DocumentsContract.getDocumentId(uri);
    final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
    final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType);
    final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled;
    if (showThumbnail) {
        final Bitmap cachedResult = mCache.get(uri);
        if (cachedResult != null) {
            iconThumb.setImageBitmap(cachedResult);
            cacheHit = true;
            iconMimeBackground.setVisibility(View.GONE);
        } else {
            iconThumb.setImageDrawable(null);
            final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb,
                    iconMime, iconMimeBackground);
            iconThumb.setTag(task);
            ProviderExecutor.forAuthority(docAuthority).execute(task);
        }
    }

    if (cacheHit) {
        iconMime.setImageDrawable(null);
        iconMime.setAlpha(0f);
        iconThumb.setAlpha(1f);
    } else {
        // Add a mime icon if the thumbnail is being loaded in the background.
        iconThumb.setImageDrawable(null);
        iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon));
        iconMime.setAlpha(1f);
        iconThumb.setAlpha(0f);
    }
}
 
Example 9
Project: ayo-menu   File: CustomRadioGroup.java   View Source Code Vote up 5 votes
public RadioButton(int unSelected,int selected,String string) {
	v=inflater.inflate(ID_LAYOUT, null);
	top=(ImageView)v.findViewById(ID_IMAGE_TOP);
	bottom=(ImageView)v.findViewById(ID_IMAGE_BOTTOM);
	text=(TextView)v.findViewById(ID_TEXT);
	news=(TextView)v.findViewById(ID_NEWS);
	
	top.setImageResource(unSelected);
	top.setAlpha(1.0f);
	bottom.setImageResource(selected);
	bottom.setAlpha(0.0f);
	text.setText(string);
	news.setVisibility(INVISIBLE);
	v.setLayoutParams(itemLayoutParams);
}
 
Example 10
Project: TestChat   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
public void initView() {
    LogUtil.e("initMain123");
    RecentFragment recentFragment = new RecentFragment();
    ContactsFragment contactsFragment = new ContactsFragment();
    InvitationFragment invitationFragment = new InvitationFragment();
    ShareMessageFragment shareMessageFragment = new ShareMessageFragment();
    mFragments[0] = recentFragment;
    mFragments[1] = contactsFragment;
    mFragments[2] = invitationFragment;
    mFragments[3] = shareMessageFragment;
    container = (DragLayout) findViewById(R.id.drag_container);
    menuDisplay = (RecyclerView) findViewById(R.id.rev_menu_display);
    nick = (TextView) findViewById(R.id.tv_menu_nick);
    signature = (TextView) findViewById(R.id.tv_menu_signature);
    avatar = (RoundAngleImageView) findViewById(R.id.riv_menu_avatar);
    headLayout = (RelativeLayout) findViewById(R.id.rl_menu_head_layout);
    bg = (ImageView) findViewById(R.id.iv_main_bg);
    net = (TextView) findViewById(R.id.tv_main_net);
    weatherCity = (TextView) findViewById(R.id.tv_menu_weather_city);
    weatherTemperature = (TextView) findViewById(R.id.tv_menu_weather_temperature);
    bottomLayout = (LinearLayout) findViewById(R.id.ll_menu_bottom_container);
    bg.setAlpha((float) 0.0);
    menuDisplay.setLayoutManager(new LinearLayoutManager(this));
    menuDisplay.setHasFixedSize(true);
    menuDisplay.setItemAnimator(new DefaultItemAnimator());
    container.setListener(this);
    headLayout.setOnClickListener(this);
    net.setOnClickListener(this);
    bottomLayout.setOnClickListener(this);
    initActionBarView();
}
 
Example 11
Project: easyfilemanager   File: IconHelper.java   View Source Code Vote up 5 votes
/**
 * Load thumbnails for a directory list item.
 * @param uri The URI for the file being represented.
 * @param mimeType The mime type of the file being represented.
 * @param docFlags Flags for the file being represented.
 * @param iconThumb The itemview's thumbnail icon.
 * @param iconMimeBackground
 * @return
 */
public void loadThumbnail(Uri uri, String path, String mimeType, int docFlags, int docIcon,
                          ImageView iconMime, ImageView iconThumb, View iconMimeBackground) {
    boolean cacheHit = false;

    final String docAuthority = uri.getAuthority();
    String docId = DocumentsContract.getDocumentId(uri);
    final boolean supportsThumbnail = (docFlags & Document.FLAG_SUPPORTS_THUMBNAIL) != 0;
    final boolean allowThumbnail = MimePredicate.mimeMatches(MimePredicate.VISUAL_MIMES, mimeType);
    final boolean showThumbnail = supportsThumbnail && allowThumbnail && mThumbnailsEnabled;
    if (showThumbnail) {
        final Bitmap cachedResult = mCache.get(uri);
        if (cachedResult != null) {
            iconThumb.setImageBitmap(cachedResult);
            cacheHit = true;
            iconMimeBackground.setVisibility(View.GONE);
        } else {
            iconThumb.setImageDrawable(null);
            final LoaderTask task = new LoaderTask(uri, path, mimeType, mThumbSize, iconThumb,
                    iconMime, iconMimeBackground);
            iconThumb.setTag(task);
            ProviderExecutor.forAuthority(docAuthority).execute(task);
        }
    }

    if (cacheHit) {
        iconMime.setImageDrawable(null);
        iconMime.setAlpha(0f);
        iconThumb.setAlpha(1f);
    } else {
        // Add a mime icon if the thumbnail is being loaded in the background.
        iconThumb.setImageDrawable(null);
        iconMime.setImageDrawable(getDocumentIcon(mContext, docAuthority, docId, mimeType, docIcon));
        iconMime.setAlpha(1f);
        iconThumb.setAlpha(0f);
    }
}
 
Example 12
Project: aos-Video   File: BrowserWithShowHeader.java   View Source Code Vote up 5 votes
public void onViewCreated(View v, Bundle save){
    super.onViewCreated(v, save);
    ImageViewSetterConfiguration config = ImageViewSetterConfiguration.Builder.createNew()
            .setUseCache(false)
            .build();
    mApplicationFrameLayout =  ((MainActivity) getActivity()).getGlobalBackdropView();
    mApplicationBackdrop = (ImageView) (((MainActivity) getActivity()).getGlobalBackdropView().findViewById(R.id.backdrop));
    mApplicationBackdrop.setAlpha(0f);
    mBackgroundSetter = new ImageViewSetter(getActivity(), config);
    mHeaderView = LayoutInflater.from(getContext()).inflate(R.layout.browser_item_header_show, null);
    mHeaderView.findViewById(R.id.loading).setVisibility(View.VISIBLE);
    addHeaderView();
}
 
Example 13
Project: ECardFlow   File: BlurAnimMode.java   View Source Code Vote up 5 votes
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
    float mFraction = (float) Math.cos(2 * Math.PI * position);
    if (mFraction < 0)
        mFraction = 0;
        ivBg.setAlpha(mFraction);
}
 
Example 14
Project: SuperNote   File: RvEditFolderAdapter.java   View Source Code Vote up 5 votes
private void setFirstItemOrNormal(BaseViewHolder helper){

        ImageView ivRename=helper.getView(R.id.iv_edit_folder_rename);
        CheckBox checkBox=helper.getView(R.id.cb_edit_folder);
        RelativeLayout rlRoot=helper.getView(R.id.rl_edit_folder);

        // 第一行(随手记)不可编辑
        if(helper.getLayoutPosition()==0){

            checkBox.setAlpha(0.26F);
            rlRoot.setClickable(false);

        } else {

            ivRename.setAlpha(0.54F);
            ivRename.setClickable(true);

            checkBox.setAlpha(0.87F);
            rlRoot.setClickable(true);

        }
    }
 
Example 15
Project: ViewPagerHelper   File: ZoomIndicator.java   View Source Code Vote up 5 votes
public void addPagerData(PageBean bean, ViewPager viewPager) {
    if (bean != null){
        mCount = bean.datas.size();
        //这里加小圆点
        for (int i = 0; i < mCount; i++) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT);
            if (i == mCount - 1){ //防止indicator的宽度为wrap_content,放大后被遮盖住的问题
                params.setMargins(mLeftMargin,0,mLeftMargin,0);
            }else{
                params.setMargins(mLeftMargin,0,0,0);
            }

            ImageView imageView = new ImageView(mContext);
        /*    if (mSelector == 0){
            }else {
            }*/
            imageView.setBackgroundResource(mSelector);
            imageView.setLayoutParams(params);
            imageView.setAlpha(mAlpha_min);

            addView(imageView);
        }
    }
    if (bean.openview != null){
        mOpenView = bean.openview;
    }
    if (viewPager != null){
        viewPager.addOnPageChangeListener(this);
    }
}
 
Example 16
Project: GravityBox   File: TouchInterceptor.java   View Source Code Vote up 5 votes
private void startDragging(Bitmap bm, int x, int y) {
      stopDragging();

      mWindowParams = new WindowManager.LayoutParams();
      mWindowParams.gravity = Gravity.TOP | Gravity.START;
      mWindowParams.x = x;
      mWindowParams.y = y - mDragPoint + mCoordOffset;

      mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
      mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
      mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
              | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
              | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
              | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN
              | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS;
      mWindowParams.format = PixelFormat.TRANSLUCENT;
      mWindowParams.windowAnimations = 0;

      Context context = getContext();
      ImageView v = new ImageView(context);
      int backGroundColor = context.getResources().getColor(R.color.dragndrop_background);
v.setAlpha((float) 0.7);
      v.setBackgroundColor(backGroundColor);
      v.setImageBitmap(bm);
      mDragBitmap = bm;

      mWindowManager = (WindowManager) context.getSystemService("window");
      mWindowManager.addView(v, mWindowParams);
      mDragView = v;
  }
 
Example 17
Project: OddLauncher   File: SettingsHelper.java   View Source Code Vote up 4 votes
public void setAlphaMainButtons(ImageView view, float alpha) {
    view.setAlpha(alpha / 10);
}
 
Example 18
Project: OddLauncher   File: SettingsHelper.java   View Source Code Vote up 4 votes
public void setAlphaSearchButton(ImageView btn, float alpha) {
    btn.setAlpha(alpha / 10);
}
 
Example 19
Project: editor-sql   File: FeThumbUtils.java   View Source Code Vote up 4 votes
public static void setFileThumbAlpha(String name, ImageView thumb) {
    if (thumb != null) {
        thumb.setAlpha(FileUtils.isHide(name) ? HIDE_FILE_ALPHA : NORMAL_FILE_ALPHA);
    }
}
 
Example 20
Project: cordova-plugin-video-picture-preview-picker-V2   File: VideoPicturePickerActivity.java   View Source Code Vote up 4 votes
private void selectPictureVideo(int index) {
    View v = DeviceImageVideoGridview.getChildAt(index -
            DeviceImageVideoGridview.getFirstVisiblePosition());
    View vOld = DeviceImageVideoGridview.getChildAt(selectedElement -
            DeviceImageVideoGridview.getFirstVisiblePosition());


    if (v == null)
        return;
    ImageView selectionbox = (ImageView) v.findViewById(fakeR.getId("id", "selectionbox"));
    if (DeviceImageVideoGridview_Adapter.isMultiSelectionActiv()) {
        if (data.get(index).isMultiSelectionState()) {
            data.get(index).setMultiSelectionState(false);
            Glide.with(this).load(fakeR.getId("drawable", "selected_not"))
                    .override(100, 100)
                    .centerCrop()
                    .skipMemoryCache(true)
                    .diskCacheStrategy(DiskCacheStrategy.NONE)
                    .into(selectionbox);
            SelectedElement_List.remove(data.get(index));


        } else {
            if (!(SelectedElement_List.size() == limit_Select)) {
                data.get(index).setMultiSelectionState(true);
                Glide.with(this).load(fakeR.getId("drawable", "selected"))
                        .override(100, 100)
                        .centerCrop()
                        .skipMemoryCache(true)
                        .diskCacheStrategy(DiskCacheStrategy.NONE)
                        .into(selectionbox);
                SelectedElement_List.add(data.get(index));
            } else
                Toast.makeText(getBaseContext(), getResources().getString(fakeR.getId("string", "vpp_limitMultiselect")),
                        Toast.LENGTH_SHORT).show();


        }
        countSelection.setText(SelectedElement_List.size() + "");
        if (SelectedElement_List.size() == 0) {
            doneText.setEnabled(false);
            done_button.setEnabled(false);
            done_button.setAlpha(0.5f);

        } else {
            doneText.setEnabled(true);
            done_button.setEnabled(true);
            done_button.setAlpha(1f);
        }
    } else {
        doneText.setEnabled(true);
        done_button.setEnabled(true);
        done_button.setAlpha(1f);
    }

    if (selectedElement != index) {
        ImageView image = (ImageView) v.findViewById(fakeR.getId("id", "imageS"));

        if (vOld != null) {
            ImageView theOld = (ImageView) vOld.findViewById(fakeR.getId("id", "imageS"));

            theOld.setAlpha(1f);
        }
        image.setAlpha(0.5f);
    }


}