List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.charbgr.BlurNavigationDrawer.v4.BlurActionBarDrawerToggle.java
/** * We make a fake ImageView with width and height MATCH_PARENT. * This ImageView will host the blurred snapshot/bitmap. *//*from w ww .j a v a2 s . co m*/ private void init() { 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); mDrawerLayout.post(new Runnable() { @Override public void run() { // Add the ImageViewiew not in the last position. // Otherwise, it will be shown in NavigationDrawer mDrawerLayout.addView(mBlurredImageView, 1); } }); }
From source file:dev.vision.shopping.center.Fragments.GourmetFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { v = new FrameLayout(getActivity()); View fm = inflater.inflate(R.layout.tabbed_list_fragment, null); ((FrameLayout) v).addView(fm);/*from ww w . j a v a2 s. com*/ tabs = (TabHost) v.findViewById(android.R.id.tabhost); //Id of tab host iv = new ImageView(getActivity()); ((FrameLayout) v).addView(iv); iv.setImageResource(R.drawable.gourmetb); iv.setBackgroundColor(Color.WHITE); iv.setScaleType(ScaleType.CENTER_INSIDE); Animation mLoadAnimation = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out); mLoadAnimation.setStartOffset(1000); mLoadAnimation.setDuration(1500); mLoadAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { iv.setVisibility(View.GONE); } }); iv.setAnimation(mLoadAnimation); return v; }
From source file:com.aokp.romcontrol.github.tasks.GetJSONChangelogTask.java
protected void onPreExecute() { // start with a clean view, always mCategory.removeAll();// ww w . j av a2 s.co m mCategory.setTitle(mContext.getString(R.string.loading_projects)); 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:com.bruce.study.demo.studydata.viewpage.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); LayoutInflater inflater = getLayoutInflater(); pageViews = new ArrayList<>(5); pageViews.add(inflater.inflate(R.layout.viewpager_item_01, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_02, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_03, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_04, null)); imageViews = new ImageView[pageViews.size()]; ViewGroup main = (ViewGroup) inflater.inflate(R.layout.viewpager_activity, null); ViewGroup group = (ViewGroup) main.findViewById(R.id.ll_viewgroup); ViewPager viewPager = (ViewPager) main.findViewById(R.id.vp_guide); for (int i = 0; i < pageViews.size(); i++) { ImageView imageView = new ImageView(ViewPagerActivity.this); imageView.setLayoutParams(new ViewGroup.LayoutParams(20, 20)); imageView.setPadding(20, 0, 20, 0); imageViews[i] = imageView;/*from ww w.j a v a 2 s . c o m*/ if (i == 0) { imageViews[i].setBackgroundResource(R.drawable.viewpager_indicator_focused); } else { imageViews[i].setBackgroundResource(R.drawable.viewpage_indicator); } group.addView(imageViews[i]); } setContentView(main); viewPager.setAdapter(new MyViewPagerAdapter()); viewPager.setOnPageChangeListener(new PageChangeListener()); }
From source file:com.thefinestartist.simplewebviewfragment.SimpleWebViewFragment.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) @Override// ww w . ja v a 2 s.c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.web_view, container, false); mPbar = (ProgressBar) view.findViewById(R.id.web_view_progress); mView = (FrameLayout) view.findViewById(R.id.web_view); mView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mImageView = new ImageView(getActivity()); mImageView.setBackgroundColor(getResources().getColor(android.R.color.white)); mImageView.setImageResource(R.drawable.big_image_loading); mImageView.setScaleType(ScaleType.CENTER_INSIDE); mImageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mImageView.post(new Runnable() { @Override public void run() { ((AnimationDrawable) mImageView.getDrawable()).start(); } }); mView.addView(mImageView); mWebview = new WebView(getActivity()); mWebview.setVisibility(View.GONE); mWebview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); if (mUrl != null) { mWebview.setWebViewClient(new MyWebViewClient()); mWebview.setWebChromeClient(new MyWebChromeClient()); mWebview.getSettings().setPluginState(PluginState.ON); mWebview.getSettings().setUseWideViewPort(true); mWebview.getSettings().setDefaultZoom(ZoomDensity.FAR); mWebview.getSettings().setBuiltInZoomControls(true); mWebview.getSettings().setSupportZoom(true); mWebview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); mWebview.getSettings().setAllowFileAccess(true); mWebview.getSettings().setDomStorageEnabled(true); mWebview.getSettings().setJavaScriptEnabled(true); mWebview.getSettings().setAppCacheEnabled(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) mWebview.getSettings().setDisplayZoomControls(false); mWebview.loadUrl(mUrl); } mView.addView(mWebview); mBackBtn = (ImageButton) view.findViewById(R.id.web_view_btn_back); mFowardBtn = (ImageButton) view.findViewById(R.id.web_view_btn_forward); mRefreshBtn = (ImageButton) view.findViewById(R.id.web_view_btn_refresh); mRefreshPbar = (ProgressBar) view.findViewById(R.id.loading); mShareBtn = (ImageButton) view.findViewById(R.id.web_view_btn_share); mBackBtn.setOnClickListener(this); mFowardBtn.setOnClickListener(this); mRefreshBtn.setOnClickListener(this); mShareBtn.setOnClickListener(this); updateActionView(); return view; }
From source file:com.aokp.romcontrol.github.tasks.GetCommitsInProjectTask.java
protected void onPreExecute() { // show commit after we load next set mCategory.setTitle(mContext.getString(R.string.loading_commits)); mCategory.setOrderingAsAdded(true);//from w w w.j a v a2 s .c om 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:com.kuloud.android.unity.ui.widget.steprefresh.PullToRefreshView.java
public PullToRefreshView(Context context, AttributeSet attrs) { super(context, attrs); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTotalDragDistance = UIUtils.dpToPxInt(context, DRAG_MAX_DISTANCE); mRefreshView = new ImageView(context); setRefreshStyle();/*www . j a v a2 s . c om*/ addView(mRefreshView); setWillNotDraw(false); ViewCompat.setChildrenDrawingOrderEnabled(this, true); }
From source file:com.filemanager.free.adapters.DrawerAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (values.get(position).isSection()) { ImageView view = new ImageView(context); if (m.theme1 == 0) view.setImageResource(R.color.divider); else//from w w w . j ava2s . c om view.setImageResource(R.color.divider_dark); view.setClickable(false); view.setFocusable(false); if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE); else view.setBackgroundResource(R.color.background_material_dark); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17))); view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8)); return view; } else { View view = inflater.inflate(R.layout.drawerrow, parent, false); final TextView txtTitle = (TextView) view.findViewById(R.id.firstline); final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (m.theme1 == 0) { view.setBackgroundResource(R.drawable.safr_ripple_white); } else { view.setBackgroundResource(R.drawable.safr_ripple_black); } view.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { m.selectItem(position); } // TODO: Implement this method }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!getItem(position).isSection()) // not to remove the first bookmark (storage) and permanent bookmarks if (position > m.storage_count && position < values.size() - 7) { EntryItem item = (EntryItem) getItem(position); String path = (item).getPath(); if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) { m.renameBookmark((item).getTitle(), path); } else if (path.startsWith("smb:/")) { m.showSMBDialog(item.getTitle(), path, true); } } else if (position < m.storage_count) { String path = ((EntryItem) getItem(position)).getPath(); if (!path.equals("/")) new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1); } // return true to denote no further processing return true; } }); txtTitle.setText(((EntryItem) (values.get(position))).getTitle()); imageView.setImageDrawable(getDrawable(position)); imageView.clearColorFilter(); if (myChecked.get(position)) { if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee")); else view.setBackgroundColor(Color.parseColor("#ff424242")); imageView.setColorFilter(fabskin); txtTitle.setTextColor(Color.parseColor(m.fabskin)); } else { if (m.theme1 == 0) { imageView.setColorFilter(Color.parseColor("#666666")); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black)); } else { imageView.setColorFilter(Color.WHITE); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); } } return view; } }
From source file:com.vista.zoonv1.CategoriaFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.categoriafragment, container, false); LinearLayout layout = (LinearLayout) rootView.findViewById(R.id.categoria_linerlayout); // /////////////////////////////////////////// // LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, // LayoutParams.MATCH_PARENT); // FrameLayout fl = new FrameLayout(getActivity()); // fl.setLayoutParams(params); // final int margin = (int) TypedValue.applyDimension( // TypedValue.COMPLEX_UNIT_DIP, 1, getResources() // .getDisplayMetrics()); // TextView v = new TextView(getActivity()); // params.setMargins(margin, margin, margin, margin); // v.setLayoutParams(params); // v.setLayoutParams(params); // v.setGravity(Gravity.CENTER); // v.setBackgroundResource(R.drawable.background_card); // v.setText("Aqui poner una listta de item: Nro " + (position + 1)); // ScrollView scrollView = new ScrollView(getActivity()); int min = 0;/* ww w . j a v a 2 s . com*/ int max = 10; Random r = new Random(); for (int i = 0; i < _IMG_SUBCAT.length; i++) { ImageView imageView = new ImageView(getActivity()); int i1 = r.nextInt(max - min + 1) + min; if (i1 % 2 == 0) { imageView.setImageResource(_IMG_SUBCAT[i]); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(60, 60); params.setMargins(5, 20, 5, 3); imageView.setLayoutParams(params); layout.addView(imageView); } } // fl.addView(scrollView); return rootView; }
From source file:com.wallerlab.compcellscope.Image_Gallery.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image__gallery); counter = 0;//from w ww . j av a 2 s .co m final ImageView currPic = new ImageView(this); DisplayMetrics metrics = this.getResources().getDisplayMetrics(); final int screen_width = metrics.widthPixels; SharedPreferences settings = getSharedPreferences(Folder_Chooser.PREFS_NAME, 0); //SharedPreferences.Editor edit = settings.edit(); String path = settings.getString(Folder_Chooser.location_name, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString()); //Log.d(LOG, " | " + path + " | "); TextView text1 = (TextView) findViewById(R.id.text1); final TextView text2 = (TextView) findViewById(R.id.text2); text1.setText(path); File directory = new File(path); // get all the files from a directory File[] dump_files = directory.listFiles(); Log.d(LOG, dump_files.length + " "); final File[] fList = removeElements(dump_files, "info.json"); Log.d(LOG, "Filtered Length: " + fList.length); Arrays.sort(fList, new Comparator<File>() { @Override public int compare(File file, File file2) { String one = file.toString(); String two = file2.toString(); //Log.d(LOG, "one: " + one); //Log.d(LOG, "two: " + two); int num_one = Integer.parseInt(one.substring(one.lastIndexOf("(") + 1, one.lastIndexOf(")"))); int num_two = Integer.parseInt(two.substring(two.lastIndexOf("(") + 1, two.lastIndexOf(")"))); return num_one - num_two; } }); try { writeJsonFile(fList); } catch (JSONException e) { Log.d(LOG, "JSON WRITE FAILED"); } //List names programattically LinearLayout myLinearLayout = (LinearLayout) findViewById(R.id.linear_table); final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, screen_width + 4); myLinearLayout.setOrientation(LinearLayout.VERTICAL); if (fList != null) { File cur_pic = fList[0]; BitmapFactory.Options opts = new BitmapFactory.Options(); Log.d(LOG, "\n File Location: " + cur_pic.getAbsolutePath() + " \n" + " Parent: " + cur_pic.getParent().toString() + "\n"); Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); currPic.setLayoutParams(params); currPic.setImageBitmap(myImage); currPic.setId(View.generateViewId()); text2.setText(cur_pic.getName()); } myLinearLayout.addView(currPic); //Seekbar seekBar = (SeekBar) findViewById(R.id.seekBar); seekBar.setEnabled(true); seekBar.setMax(fList.length - 1); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { int progress = 0; int length = fList.length; @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { setCounter(i); if (getCounter() <= fList.length) { File cur_pic = fList[getCounter()]; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); int image_width = opts.outWidth; int image_height = opts.outHeight; int sampleSize = image_width / screen_width; opts.inSampleSize = sampleSize; text2.setText(cur_pic.getName()); opts.inJustDecodeBounds = false; myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); currPic.setImageBitmap(myImage); } } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); //Make Button Layout LinearLayout buttonLayout = new LinearLayout(this); buttonLayout.setOrientation(LinearLayout.HORIZONTAL); LinearLayout.LayoutParams LLParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f); buttonLayout.setLayoutParams(LLParams); buttonLayout.setId(View.generateViewId()); //Button Layout Params LinearLayout.LayoutParams param_button = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0f); //Prev Pic Button prevPic = new Button(this); prevPic.setText("Previous"); prevPic.setId(View.generateViewId()); prevPic.setLayoutParams(param_button); prevPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (fList != null) { decrementCounter(); if (getCounter() >= 0) { File cur_pic = fList[getCounter()]; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); int image_width = opts.outWidth; int image_height = opts.outHeight; int sampleSize = image_width / screen_width; opts.inSampleSize = sampleSize; text2.setText(cur_pic.getName()); opts.inJustDecodeBounds = false; myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); //Log.d(LOG, getCounter() + ""); seekBar.setProgress(getCounter()); currPic.setImageBitmap(myImage); } else { setCounter(0); } } else { Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT); setCounter(getCounter() - 1); } } }); buttonLayout.addView(prevPic); // Next Picture Button Button nextPic = new Button(this); nextPic.setText("Next"); nextPic.setId(View.generateViewId()); nextPic.setLayoutParams(param_button); buttonLayout.addView(nextPic); nextPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (fList != null) { incrementCounter(); if (getCounter() < fList.length) { File cur_pic = fList[getCounter()]; BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inJustDecodeBounds = true; Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); int image_width = opts.outWidth; int image_height = opts.outHeight; int sampleSize = image_width / screen_width; opts.inSampleSize = sampleSize; text2.setText(cur_pic.getName()); opts.inJustDecodeBounds = false; myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts); //Log.d(LOG, getCounter() + ""); seekBar.setProgress(getCounter()); currPic.setImageBitmap(myImage); } else { setCounter(getCounter() - 1); } } else { Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT); setCounter(getCounter() - 1); } } }); myLinearLayout.addView(buttonLayout); }