Example usage for android.widget ImageView setBackgroundResource

List of usage examples for android.widget ImageView setBackgroundResource

Introduction

In this page you can find the example usage for android.widget ImageView setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:Main.java

public static void showPopWindow(Context context, View parent, int drawableId) {
    if (drawableId == 0) {
        return;/* w  ww.  j  av a  2s. co m*/
    }
    if (pop == null) {
        ImageView imageView = null;
        imageView = new ImageView(context);
        imageView.setBackgroundResource(drawableId);
        pop = new PopupWindow(imageView, LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (pop != null) {
                    pop.dismiss();
                    pop = null;
                }
            }
        });
    }
    if (!pop.isShowing()) {
        pop.showAtLocation(parent, Gravity.BOTTOM, 0, 0);

    }
}

From source file:Main.java

/**
 * Replaces an ImageView's background AnimationDrawable with the specified resource id in the
 * future. Calls start() on the AnimationDrawable once it has been replaced. 
 * @param handler The Handler for the Activity in which the animation will run.
 * @param imageView An ImageView that has a background that can be casted to AnimationDrawable.
 * @param animationResourceId The animation's resource id.
 * @param color The color to apply to the AnimationDrawable. 
 * @param millisFromNow The number of milliseconds to wait before replacing the animation. 
 *//*w  w  w  .  j a v a  2 s.c  o  m*/
public static void replaceAnimationInFuture(final Handler handler, final ImageView imageView,
        final int animationResourceId, final int color, long millisFromNow) {
    handler.postAtTime(new Runnable() {
        @Override
        public void run() {
            imageView.setBackgroundResource(animationResourceId);
            imageView.getBackground().mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);
            ((AnimationDrawable) (imageView.getBackground())).start();
        }
    }, SystemClock.uptimeMillis() + millisFromNow);
}

From source file:com.xiaoya.framepager.SuperAwesomeCardFragment.java

/**
 * /*from w w  w .  j av  a2 s .com*/
 * 
 * @param cur
 */
public static void changePointView(int cur) {
    //LinearLayout pointLinear = (LinearLayout) findViewById(R.id.gallery_point_linear);
    View view = linear_point.getChildAt(index);
    View curView = linear_point.getChildAt(cur);
    if (view != null && curView != null) {
        ImageView pointView = (ImageView) view;
        ImageView curPointView = (ImageView) curView;
        pointView.setBackgroundResource(R.drawable.feature_point);
        curPointView.setBackgroundResource(R.drawable.feature_point_cur);
        index = cur;
    }
}

From source file:br.com.lealweb.aventuradoconhecimento.GuideFragment.java

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ImageView imageView = (ImageView) getView().findViewById(R.id.image);
    imageView.setBackgroundResource(bgRes);
}

From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.WakeupFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.setting_wakeup, null);
    final ImageView image = (ImageView) root.findViewById(R.id.animView001);
    image.setBackgroundResource(R.drawable.sphero_light);

    return root;/*from w ww .j av a  2  s . co  m*/
}

From source file:com.jaspersoft.android.jaspermobile.util.resource.viewbinder.ReportResourceBinder.java

@Override
public void setIcon(ImageView imageView, JasperResource jasperResource) {
    imageView.setBackgroundResource(R.drawable.bg_resource_icon_grey);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    loadFromNetwork(imageView, jasperResource, getDisplayImageOptions(R.drawable.ic_report));
}

From source file:com.jaspersoft.android.jaspermobile.util.resource.viewbinder.ReportResourceBinder.java

@Override
public void setThumbnail(ImageView imageView, JasperResource jasperResource) {
    imageView.setBackgroundResource(R.drawable.bg_gradient_grey);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    loadFromNetwork(imageView, jasperResource, getDisplayImageOptions(R.drawable.im_thumbnail_report));
}

From source file:com.flan.stock.fragment.FragmentNewsYw.java

/**
 * ???// w ww .j  a v a  2  s  . com
 */
private void getTouTiaoData() {

    LayoutParams para = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    ImageView img1 = new ImageView(context);
    img1.setBackgroundResource(R.drawable.img_ipo);
    img1.setLayoutParams(para);
    ImageView img2 = new ImageView(context);
    img2.setBackgroundColor(Color.BLUE);
    img2.setLayoutParams(para);
    toutiaoList = new ArrayList<>();
    toutiaoList.add(img1);
    toutiaoList.add(img2);
}

From source file:com.pixate.freestyle.MainFrameActivity.java

/**
 * Convenient method to add a tab to the tab widget at bottom.
 * //from   ww  w  . j  ava  2s.c  o  m
 * @param resId The resource id of image shown on indicator
 * @param content The class type of content
 */
private void addTab(int resId, Class<? extends Fragment> content) {
    ImageView indicator = new ImageView(this);
    indicator.setScaleType(ScaleType.CENTER_INSIDE);
    indicator.setBackgroundResource(R.drawable.tab_bg);
    indicator.setImageResource(resId);
    TabSpec spec = tabHost.newTabSpec(content.getSimpleName()).setIndicator(indicator);
    tabHost.addTab(spec, content, null);
}

From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.PairingFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.setting_pairing, null);

    final ImageView image = (ImageView) root.findViewById(R.id.animView);
    image.setBackgroundResource(R.drawable.sphero_light);

    Button button = (Button) root.findViewById(R.id.btnSetting);
    button.setOnClickListener(new OnClickListener() {
        @Override//from   w w  w.jav a 2  s  .c  o  m
        public void onClick(final View v) {
            startActivity(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS));
        }
    });
    View permission = root.findViewById(R.id.ble_permission);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        permission.setVisibility(View.GONE);
    } else {
        permission.setVisibility(View.VISIBLE);
    }

    mBlePermissionBtn = (Button) root.findViewById(R.id.button_permission);
    mBlePermissionBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BleUtils.isBLEPermission(getActivity())) {
                openAndroidSettings();
            } else {
                requestPermissions();
            }
        }
    });
    return root;
}