List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:at.wada811.imageslider.ImageSliderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mImageSwitcher = new ImageSwitcher(getActivity()); mImageSwitcher.setFactory(new ViewFactory() { @Override//ww w . j a va2s .com public View makeView() { return new ImageView(getActivity()); } }); mImageSwitcher.setOnTouchListener(mSwipeTouchListener); setImageBitmap(BitmapUtils.createBitmapFromResource(getActivity(), R.drawable.ic_launcher)); return mImageSwitcher; }
From source file:edu.htl3r.schoolplanner.gui.timetable.ViewPagerIndicator.java
/** * Add drawables for arrows// w w w . jav a2s.c o m * * @param prev Left pointing arrow * @param next Right pointing arrow */ public void setArrows(Drawable prev, Drawable next) { this.mPrevArrow = new ImageView(getContext()); this.mPrevArrow.setImageDrawable(prev); this.mNextArrow = new ImageView(getContext()); this.mNextArrow.setImageDrawable(next); LinearLayout.LayoutParams arrowLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); arrowLayoutParams.gravity = Gravity.CENTER; mPreviousGroup.removeAllViews(); mPreviousGroup.addView(mPrevArrow, arrowLayoutParams); mPreviousGroup.addView(mPrevious, arrowLayoutParams); mPrevious.setPadding(PADDING, 0, 0, 0); mNext.setPadding(0, 0, PADDING, 0); mArrowPadding = PADDING + prev.getIntrinsicWidth(); mNextGroup.addView(mNextArrow, arrowLayoutParams); }
From source file:com.pixate.freestyle.MainFrameActivity.java
/** * Convenient method to add a tab to the tab widget at bottom. * //from ww w . j a v a 2s. c om * @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:com.sismics.bluractionbar.BlurActionBarDrawerToggle.java
/** * This function must be invoked if "default" (1st) constructor is called * or if you want to change the blurred layout. * <p/>//w w w . j av a 2s . c o m * We make a fake ImageView with width and height MATCH_PARENT. * This ImageView will host the blurred snapshot/bitmap. * * @param layout A {@link android.widget.RelativeLayout} to take snapshot of it. * @param radius Blur radius */ public void init(final View layout, int radius) { this.mLayout = layout; this.mBlurRadius = radius; mBlurredImageView = new ImageView(context); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); mBlurredImageView.setLayoutParams(params); mBlurredImageView.setClickable(false); mBlurredImageView.setVisibility(View.GONE); mBlurredImageView.setScaleType(ImageView.ScaleType.FIT_XY); ((RelativeLayout) this.mLayout).addView(mBlurredImageView); }
From source file:com.multivoltage.musicat.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_drawer); bus.register(this); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitleTextColor(getResources().getColor(android.R.color.white)); setSupportActionBar(toolbar);//from w w w. ja va 2 s.c om fabAddlaylist = (FloatingActionButton) findViewById(R.id.fabAddPlayList); fabAddlaylist.hide(); fabBack = (FloatingActionButton) findViewById(R.id.fabBack); /* SET UP TOOLBAR */ toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setTitleTextColor(getResources().getColor(android.R.color.white)); imageViewHeader = new ImageView(this); imageViewHeader.setLayoutParams(new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); imageViewHeader.setAdjustViewBounds(true); imageViewHeader.setCropToPadding(false); imageViewHeader.setScaleType(ImageView.ScaleType.FIT_XY); int colResIdSlide = Utils.getTheme(this) == Const.THEME_DARK ? R.color.md_black_1000 : R.color.md_white_1000; int colResTextItem = Utils.getTheme(this) == Const.THEME_DARK ? R.color.md_white_1000 : R.color.md_black_1000; int colPrimary = Utils.getPrimaryColor(this); serverDrawerItem = new SecondaryDrawerItem().withName("Server").withTextColorRes(colResTextItem) .withIcon(GoogleMaterial.Icon.gmd_cloud_upload).withIconColor(colPrimary) .withBadgeTextColor(colPrimary); initColors(); result = new DrawerBuilder().withActivity(this).withStickyHeader(imageViewHeader).withToolbar(toolbar) .withSliderBackgroundColorRes(colResIdSlide) .addDrawerItems( new SecondaryDrawerItem().withName(getString(R.string.all_songs)) .withTextColorRes(colResTextItem).withIcon(GoogleMaterial.Icon.gmd_list) .withIconColor(colPrimary), new SecondaryDrawerItem().withName("Album").withTextColorRes(colResTextItem) .withIcon(GoogleMaterial.Icon.gmd_collections).withIconColor(colPrimary), new SecondaryDrawerItem().withName(getString(R.string.artists)) .withTextColorRes(colResTextItem).withIcon(GoogleMaterial.Icon.gmd_face) .withIconColor(colPrimary), new SecondaryDrawerItem().withName("Playlist").withTextColorRes(colResTextItem) .withIcon(GoogleMaterial.Icon.gmd_library_music).withIconColor(colPrimary), new DividerDrawerItem(), serverDrawerItem, new SecondaryDrawerItem().withName(getString(R.string.action_settings)) .withTextColorRes(colResTextItem).withIcon(GoogleMaterial.Icon.gmd_settings) .withIconColor(colPrimary), new SecondaryDrawerItem().withName("Info").withTextColorRes(colResTextItem) .withIcon(GoogleMaterial.Icon.gmd_info).withIconColor(colPrimary) ).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(AdapterView<?> adapterView, View view, int pos, long l, IDrawerItem iDrawerItem) { Fragment f = null; switch (pos) { case 0: // All songs f = new AllSongFragment(); break; case 1: // Album f = new AlbumsFragment(); break; case 2: // Artist f = new ArtistFragment(); break; case 3: // PlayList f = new PlayListFragment(); break; case 5: // server serverDialog(); break; case 6: // settings startActivityForResult(new Intent(MainActivity.this, PreferencesActivity.class), SETTING_REQUEST); break; case 7: // Info f = new InfoFragment(); break; } fabBack.setVisibility(View.INVISIBLE); if (f != null) getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, f) .commit(); return false; } }).build(); slideFragment = SlideFragment.newInstance(); getSupportFragmentManager().beginTransaction().replace(R.id.slideFragment, slideFragment).commit(); slidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_root_layout); slidingUpPanelLayout.setPanelSlideListener(this); Fragment fragAllSong = new AllSongFragment(); getSupportFragmentManager().beginTransaction().replace(R.id.frame_container, fragAllSong).commit(); initTheme(); }
From source file:com.pixate.freestyle.fragment.GridViewFragment.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub /** ImageView for each grid view item */ ImageView imageView;//w w w . ja v a 2 s. c o m if (convertView == null) { imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(mWidth, mHeight)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); } else { imageView = (ImageView) convertView; } imageView.setBackgroundResource(R.drawable.grid_item_background); return imageView; }
From source file:com.aokp.romcontrol.github.tasks.DisplayProjectsListTask.java
protected void onPreExecute() { // start with a clean view, always mFavProjects.removeAll();// w w w . j a v a 2s . com mCategory.removeAll(); mPrefsList.removeAll(mPrefsList); mCategory.setTitle(mContext.getString(R.string.loading_projects)); mCategory.setOrderingAsAdded(false); mFavPackagesStorage = new FavPackagesStorage(); if (mFavPackagesStorage.getFavProjects().size() > 0) { mPreferenceScreen.addPreference(mFavProjects); } else { mPreferenceScreen.removePreference(mFavProjects); } if (mProgressDialog == null) { mProgressDialog = new ProgressDialog(mAlertDialog.getContext()); ImageView imageView = new ImageView(mContext); imageView.setImageResource(R.drawable.octacat); mProgressDialog.show(); mProgressDialog.setContentView(R.layout.github_octacat); } }
From source file:gidaibero.android.matsol.MatrixDisplayActivity.java
private TableRow decorateTableRow(TableRow tableRow, int height, int width, int row) { ImageView leftImageView = new ImageView(this); ImageView rightImageView = new ImageView(this); leftImageView.setBackgroundResource(R.drawable.left_edge); rightImageView.setBackgroundResource(R.drawable.right_edge); if (target == R.id.matrix_button) { // we need to allocate two more elements ImageView insideLeftImageView = new ImageView(this); ImageView insideRightImageView = new ImageView(this); if (row == 0) { // should change decorators for top decorators leftImageView.setBackgroundResource(R.drawable.top_left_edge); rightImageView.setBackgroundResource(R.drawable.top_right_edge); insideLeftImageView.setBackgroundResource(R.drawable.top_right_edge); // this is not a mistake insideRightImageView.setBackgroundResource(R.drawable.top_left_edge); } else if (row == this.height - 1) { leftImageView.setBackgroundResource(R.drawable.bottom_left_edge); rightImageView.setBackgroundResource(R.drawable.bottom_right_edge); insideLeftImageView.setBackgroundResource(R.drawable.bottom_right_edge); // this is not a mistake insideRightImageView.setBackgroundResource(R.drawable.bottom_left_edge); } else {// w ww.j av a 2s. c o m insideRightImageView.setBackgroundResource(R.drawable.left_edge); insideLeftImageView.setBackgroundResource(R.drawable.right_edge); } insideLeftImageView.setLayoutParams(new LayoutParams(height, width / 5)); insideRightImageView.setLayoutParams(new LayoutParams(height, width / 5)); insideRightImageView.getLayoutParams().height = height; insideLeftImageView.getLayoutParams().height = height; insideRightImageView.getLayoutParams().width = width / 5; insideLeftImageView.getLayoutParams().width = width / 5; tableRow.addView(insideLeftImageView, this.width - 1); tableRow.addView(insideRightImageView, this.width); } else { // this is a determinant button } leftImageView.setLayoutParams(new LayoutParams(height, width / 10)); rightImageView.setLayoutParams(new LayoutParams(height, width / 10)); leftImageView.getLayoutParams().height = height; rightImageView.getLayoutParams().height = height; leftImageView.getLayoutParams().width = width / 5; rightImageView.getLayoutParams().width = width / 5; tableRow.addView(leftImageView, 0); tableRow.addView(rightImageView); return tableRow; }
From source file:org.iisgcp.waterwalk.fragment.FactFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mImageId = getArguments().getInt(Constants.INTENT_IMAGE_ID); mFactText.setText(Html.fromHtml(getArguments().getString(Constants.INTENT_DESCRIPTION))); mFactText.setMovementMethod(LinkMovementMethod.getInstance()); // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;//from w ww . j a va2 s . co m BitmapFactory.decodeResource(getResources(), mImageId, options); int maxWidth; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { maxWidth = getResources().getDisplayMetrics().widthPixels; } else { maxWidth = getResources().getDisplayMetrics().heightPixels; } final int targetWidth = maxWidth; double scale = (double) maxWidth / (double) options.outWidth; final int targetHeight = (int) (options.outHeight * scale); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mImageView = new ImageView(getActivity()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(targetWidth, targetHeight); mImageView.setLayoutParams(layoutParams); mLayout.addView(mImageView); } mImageView.setImageDrawable(null); mImageView.setBackgroundColor(getResources().getColor(R.color.gray)); // The ImageFetcher takes care of loading images into our ImageView children asynchronously mImageFetcher = ((FactViewPagerFragment) getParentFragment()).getImageFetcher(); mImageFetcher.setImageSize(targetWidth, targetHeight); }
From source file:com.facebook.android.FbDialog.java
private void createCrossImage() { mCrossImage = new ImageView(getContext()); // Dismiss the dialog when user click on the 'x' mCrossImage.setOnClickListener(new View.OnClickListener() { @Override//from ww w . ja v a 2s . com public void onClick(View v) { mListener.onCancel(); FbDialog.this.dismiss(); } }); Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.btn_close); mCrossImage.setImageDrawable(crossDrawable); /* 'x' should not be visible while webview is loading * make it visible only after webview has fully loaded */ mCrossImage.setVisibility(View.INVISIBLE); }