List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.bq.autobus.sample.LocationMapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { imageView = new ImageView(getActivity()); imageView.setScaleType(CENTER_INSIDE); return imageView; }
From source file:net.reichholf.dreamdroid.activities.ScreenShotActivity.java
@Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setTitle(getText(R.string.app_name) + " - " + getText(R.string.screenshot)); mImageView = new ImageView(this); setContentView(mImageView);// w w w.j a v a 2 s. c o m mImageView.setBackgroundColor(Color.BLACK); Bundle extras = getIntent().getExtras(); if (extras == null) { extras = new Bundle(); } mType = extras.getInt(KEY_TYPE, TYPE_ALL); mFormat = extras.getInt(KEY_FORMAT, FORMAT_PNG); mSize = extras.getInt(KEY_SIZE, 720); mFilename = extras.getString(KEY_FILENAME); reload(); }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);//from w ww .j a va2 s. c o m final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:edu.cloud.iot.reception.ocr.ScanLicense.java
private void setUpCamera() { cameraView = new CameraSurfaceView(getApplicationContext()); cameraView.parent = this; cameraView.frontCameraRequired = true; // cameraView.setCameraDisplayOrientation(this,0);//Camera.CameraInfo.CAMERA_FACING_BACK); imageResult = new ImageView(getApplicationContext()); imageResult.setBackgroundColor(Color.GRAY); frameNew = (FrameLayout) findViewById(R.id.flCamera); snapPhoto = (Button) findViewById(R.id.bCapture); Log.v("FaceRecognitionActivity", "frameNew Value = " + frameNew); frameNew.addView(imageResult);//from w ww.j ava2 s .c om frameNew.addView(cameraView); frameNew.bringChildToFront(cameraView); // asyncOCR.setParent(this); }
From source file:com.cleanwiz.applock.ui.activity.StepActivity.java
private void initPoints(int pagers) { layout_points = (LinearLayout) findViewById(R.id.layout_point); layout_points.removeAllViews();/* w w w.ja va 2 s . c o m*/ points = new ArrayList<ImageView>(); int width = ScreenUtil.dip2px(mContext, 24); int height = ScreenUtil.dip2px(mContext, 16); for (int i = 0; i < pagers; i++) { ImageView iv = new ImageView(mContext); iv.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height); if (i == 0) { iv.setImageResource(R.drawable.pager_point_white); } else { iv.setImageResource(R.drawable.pager_point_green); } layout_points.addView(iv, lp); points.add(iv); } }
From source file:com.ayo.opensource.zlayout.MainPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View itemView;/*from w w w .ja va 2 s . c o m*/ Girl girl = mAllGirlList.get(position); if (mAllImageMap.containsKey(position)) { View oldView = mAllImageMap.get(position); Object tag = oldView.getTag(); if (null != tag && tag instanceof Girl) { if (tag.equals(girl)) { itemView = oldView; container.addView(itemView); return itemView; } } container.removeView(oldView); mAllImageMap.remove(position); } ImageView imageView = new ImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); VanGogh.paper(imageView).paintMiddleImage(girl.getImageUrl(), null, null); //Glide.with(mContext).load(girl.getImageUrl()).into(imageView); imageView.setTag(girl); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageView.setLayoutParams(layoutParams); mAllImageMap.put(position, imageView); itemView = imageView; itemView.setOnClickListener(this); container.addView(itemView); return itemView; }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w .j av a2 s . c o m LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:com.linkbubble.ui.BubbleFlowActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { mDestroyed = false;/*w w w .j av a 2s .c o m*/ super.onCreate(savedInstanceState); Settings settings = Settings.get(); if (null != settings) { setTheme(settings.getDarkThemeEnabled() ? R.style.ThemeTransparentDark : R.style.ThemeTransparent); } Log.d("TAG", "!!!!! ON CREATE"); mContentViews = new ArrayList<>(); mPreClosedContentViews = new ArrayList<>(); setVisible(false); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_bubble_flow); IntentFilter filter = new IntentFilter(); filter.addAction(ACTIVITY_INTENT_NAME); LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this); bm.registerReceiver(mBroadcastReceiver, filter); MainController controller = getMainController(); if (null != controller && null != controller.mBubbleFlowDraggable) { synchronized (MainApplication.mActivitySharedLock) { MainApplication.mActivitySharedLock.notify(); } if (MainApplication.mMoveWebViewsActivityToBack) { moveTaskToBack(true); } } else { moveTaskToBack(true); mDestroyed = true; finish(); startActivityForResult(new Intent(this, EntryActivity.class), 0); } int canvasMaskHeight = getResources().getDimensionPixelSize(R.dimen.canvas_mask_height); mTopMaskView = new ImageView(this); mTopMaskView.setImageResource(R.drawable.masked_background_half); mTopMaskView.setScaleType(ImageView.ScaleType.FIT_XY); FrameLayout.LayoutParams topMaskLP = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, canvasMaskHeight); topMaskLP.gravity = Gravity.TOP; mTopMaskView.setLayoutParams(topMaskLP); addContentView(mTopMaskView, topMaskLP); }
From source file:com.android.ted.sample.viewpager.MainPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View itemView;//from w ww.ja va2 s . c o m Girl girl = mAllGirlList.get(position); if (mAllImageMap.containsKey(position)) { View oldView = mAllImageMap.get(position); Object tag = oldView.getTag(); if (null != tag && tag instanceof Girl) { if (tag.equals(girl)) { itemView = oldView; container.addView(itemView); return itemView; } } container.removeView(oldView); mAllImageMap.remove(position); } ImageView imageView = new ImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); Glide.with(mContext).load(girl.getImageUrl()).into(imageView); imageView.setTag(girl); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageView.setLayoutParams(layoutParams); mAllImageMap.put(position, imageView); itemView = imageView; itemView.setOnClickListener(this); container.addView(itemView); return itemView; }
From source file:com.ichi2.anki.multimediacard.fields.BasicImageFieldController.java
@Override public void createUI(Context context, LinearLayout layout) { mImagePreview = new ImageView(mActivity); DisplayMetrics metrics = getDisplayMetrics(); int height = metrics.heightPixels; int width = metrics.widthPixels; LinearLayout.LayoutParams p = new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); setPreviewImage(mField.getImagePath(), getMaxImageSize()); mImagePreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mImagePreview.setAdjustViewBounds(true); mImagePreview.setMaxHeight((int) Math.round(height * 0.4)); mImagePreview.setMaxWidth((int) Math.round(width * 0.6)); mBtnGallery = new Button(mActivity); mBtnGallery.setText(gtxt(R.string.multimedia_editor_image_field_editing_galery)); mBtnGallery.setOnClickListener(new View.OnClickListener() { @Override//www. j a v a2 s. c o m public void onClick(View v) { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); mActivity.startActivityForResult(i, ACTIVITY_SELECT_IMAGE); } }); mBtnCamera = new Button(mActivity); mBtnCamera.setText(gtxt(R.string.multimedia_editor_image_field_editing_photo)); mBtnCamera.setOnClickListener(new View.OnClickListener() { @SuppressLint("NewApi") @Override public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File image; File storageDir; String timeStamp = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(new Date()); try { storageDir = mActivity.getCacheDir(); image = File.createTempFile("img_" + timeStamp, ".jpg", storageDir); mTempCameraImagePath = image.getPath(); Uri uriSavedImage = FileProvider.getUriForFile(mActivity, mActivity.getApplicationContext().getPackageName() + ".apkgfileprovider", image); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); mActivity.startActivityForResult(cameraIntent, ACTIVITY_TAKE_PICTURE); } catch (IOException e) { e.printStackTrace(); } } }); // Chromebooks do not support camera capture yet. if (CompatHelper.isChromebook()) { mBtnCamera.setVisibility(View.INVISIBLE); } layout.addView(mImagePreview, android.view.ViewGroup.LayoutParams.FILL_PARENT, p); layout.addView(mBtnGallery, android.view.ViewGroup.LayoutParams.FILL_PARENT); layout.addView(mBtnCamera, android.view.ViewGroup.LayoutParams.FILL_PARENT); }