List of usage examples for android.widget ImageView ImageView
public ImageView(Context context)
From source file:com.tooltip.Tooltip.java
private View getContentView(Builder builder) { GradientDrawable drawable = new GradientDrawable(); drawable.setColor(builder.mBackgroundColor); drawable.setCornerRadius(builder.mCornerRadius); int padding = (int) builder.mPadding; TextView textView = new TextView(builder.mContext); TextViewCompat.setTextAppearance(textView, builder.mTextAppearance); textView.setText(builder.mText);/*from w ww. j a va 2s.c om*/ textView.setPadding(padding, padding, padding, padding); textView.setLineSpacing(builder.mLineSpacingExtra, builder.mLineSpacingMultiplier); textView.setTypeface(builder.mTypeface, builder.mTextStyle); if (builder.mTextSize >= 0) { textView.setTextSize(TypedValue.TYPE_NULL, builder.mTextSize); } if (builder.mTextColor != null) { textView.setTextColor(builder.mTextColor); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { textView.setBackground(drawable); } else { //noinspection deprecation textView.setBackgroundDrawable(drawable); } LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 0); textViewParams.gravity = Gravity.CENTER; textView.setLayoutParams(textViewParams); mArrowView = new ImageView(builder.mContext); mArrowView.setImageDrawable(builder.mArrowDrawable); LinearLayout.LayoutParams arrowLayoutParams; if (mGravity == Gravity.TOP || mGravity == Gravity.BOTTOM) { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowWidth, (int) builder.mArrowHeight, 0); } else { arrowLayoutParams = new LinearLayout.LayoutParams((int) builder.mArrowHeight, (int) builder.mArrowWidth, 0); } arrowLayoutParams.gravity = Gravity.CENTER; mArrowView.setLayoutParams(arrowLayoutParams); mContentView = new LinearLayout(builder.mContext); mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); mContentView.setOrientation(mGravity == Gravity.START || mGravity == Gravity.END ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); padding = (int) Util.dpToPx(5); switch (mGravity) { case Gravity.START: mContentView.setPadding(0, 0, padding, 0); break; case Gravity.TOP: case Gravity.BOTTOM: mContentView.setPadding(padding, 0, padding, 0); break; case Gravity.END: mContentView.setPadding(padding, 0, 0, 0); break; } if (mGravity == Gravity.TOP || mGravity == Gravity.START) { mContentView.addView(textView); mContentView.addView(mArrowView); } else { mContentView.addView(mArrowView); mContentView.addView(textView); } mContentView.setOnClickListener(mClickListener); mContentView.setOnLongClickListener(mLongClickListener); if (builder.isCancelable || builder.isDismissOnClick) { mContentView.setOnTouchListener(mTouchListener); } return mContentView; }
From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java
/** * /*ww w.j a v a2 s . co m*/ */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.sonvp.tooltip.Tooltip.java
private Tooltip(Builder builder) { this.builder = builder; this.anchorView = builder.anchorView; this.gravity = builder.tooltipGravity; if (builder.dismissOutsideTouch) { rootView = (ViewGroup) anchorView.getRootView(); overlay = new View(builder.context); overlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // overlay.setBackgroundColor(builder.context.getResources().getColor(android.R.color.holo_green_light)); overlay.setOnTouchListener(this); rootView.addView(overlay);/*from ww w.j a v a2 s. c om*/ } // TODO container should NOT capture all events container = new LinearLayout(builder.context); container.setOnClickListener(this); int backgroundColor = builder.backgroundColor; viewTooltip = getViewTooltip(builder, backgroundColor); rectAnchorView = getRectView(anchorView); changeGravityToolTip(); if (builder.arrowDrawable == null) { builder.arrowDrawable = new ArrowDrawable(backgroundColor, gravity); } arrow = new ImageView(builder.context); // TODO supports Gravity.NO_GRAVITY switch (gravity) { case Gravity.LEFT: container.setOrientation(LinearLayout.HORIZONTAL); container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); arrow.setImageDrawable(builder.arrowDrawable); container.addView(arrow, new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight)); break; case Gravity.RIGHT: container.setOrientation(LinearLayout.HORIZONTAL); arrow.setImageDrawable(builder.arrowDrawable); container.addView(arrow, new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight)); container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); break; case Gravity.TOP: container.setOrientation(LinearLayout.VERTICAL); container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); arrow.setImageDrawable(builder.arrowDrawable); container.addView(arrow, new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight)); break; case Gravity.BOTTOM: container.setOrientation(LinearLayout.VERTICAL); arrow.setImageDrawable(builder.arrowDrawable); container.addView(arrow, new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight)); container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); break; } popupWindow = new PopupWindow(container, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); popupWindow.setOnDismissListener(this); popupWindow.setClippingEnabled(false); popupWindow.setAnimationStyle(android.R.style.Animation); // popupWindow.setBackgroundDrawable(builder.context.getResources().getDrawable(android.R.color.holo_blue_bright)); }
From source file:cw89.cwgallerydemo.MainActivity.java
private void updateImage() { for (Uri uri : list) { int margins = Utils.convertDpPixel(mActivity, 5); int size = Utils.convertDpPixel(mActivity, 200); ImageView img = new ImageView(mActivity); LinearLayout.LayoutParams params_img = new LinearLayout.LayoutParams(size, size); params_img.topMargin = margins;//w ww . ja v a 2 s. c om params_img.bottomMargin = margins; Glide.with(this).load(uri.toString()).fitCenter().into(img); parentView.addView(img, params_img); } }
From source file:com.nike.plusgps.nikeplusgallery.MainActivity.java
/** * Handles the screen layouts based on the orientation. * The activity is not restarted when the orientation changes. *///from w ww.j a v a2 s . c o m public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // In Portrait mode the grid view is displayed if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setContentView(R.layout.activity_main_port); GridView view = (GridView) findViewById(R.id.gridView); adapter = new FlickrFeedAdapter(getApplicationContext(), R.layout.single_elem_port, flickrFeedList, dbHelper, mMemoryCache); view.setAdapter(adapter); } else { // In Landscape mode the carousel view is displayed setContentView(R.layout.activity_main_land); carouselElement = (LinearLayout) findViewById(R.id.carousel); // Compute width of a carousel item based on screen width and initial item count final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int imageWidth = (int) (displayMetrics.widthPixels / INITIAL_ITEMS_COUNT); // Fetches image url from SQLite cache ImageView imageItem; String imgURL; for (int i = 0; i < flickrFeedList.size(); ++i) { imageItem = new ImageView(this); imgURL = flickrFeedList.get(i).getMedia(); new DownloadImageTask(imageItem).execute(imgURL); imageItem.setLayoutParams(new LinearLayout.LayoutParams(imageWidth, imageWidth)); carouselElement.addView(imageItem); } } }
From source file:edu.cloud.iot.reception.ocr.FaceRecognitionActivity.java
private void setUpCamera() { cameraView = new CameraSurfaceView(getBaseContext()); 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("EDebug::FaceRecognitionActivity", "frameNew Value = " + frameNew); frameNew.addView(imageResult);// w w w. ja va2s.c o m frameNew.addView(cameraView); frameNew.bringChildToFront(cameraView); }
From source file:com.almeida.matheus.androidslidingtabmaterialdesigner.Components.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link (int, int)}.//from w w w . jav a2 s. c o m */ protected ImageView createDefaultTabView(Context context) { ImageView iconTab = new ImageView(context); iconTab.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); iconTab.setBackgroundResource(outValue.resourceId); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); iconTab.setPadding(padding, padding, padding, padding); return iconTab; }
From source file:org.addhen.smssync.presentation.view.ui.activity.GettingStartedActivity.java
private void renderViewPageIndicators() { float scale = getResources().getDisplayMetrics().density; int padding = (int) (5 * scale + 0.5f); for (int i = 0; i < mNumOfPages - 1; i++) { ImageView circle = new ImageView(this); circle.setImageResource(R.drawable.ic_swipe_indicator_white_18dp); circle.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); circle.setAdjustViewBounds(true); circle.setPadding(padding, 0, padding, 0); mCircles.addView(circle);//from w w w .j a va 2 s.c o m } setIndicator(0); }
From source file:com.cellbots.local.EyesView.java
public EyesView(CellDroidActivity ct, String url, boolean torch) { Log.e("remote eyes", "started " + url); mParent = ct;//w w w . jav a2 s. com putUrl = url; PowerManager pm = (PowerManager) ct.getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE | PowerManager.ACQUIRE_CAUSES_WAKEUP, "Cellbot Eyes"); mWakeLock.acquire(); out = new ByteArrayOutputStream(); if (putUrl != null) { isLocalUrl = putUrl.contains("127.0.0.1") || putUrl.contains("localhost"); server = putUrl.replace("http://", ""); server = server.substring(0, server.indexOf("/")); mTorchMode = torch; resetConnection(); mHttpState = new HttpState(); } ct.setContentView(R.layout.eyes_main); mPreview = (SurfaceView) ct.findViewById(R.id.eyes_preview); mHolder = mPreview.getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); mPreview.setOnClickListener(new OnClickListener() { public void onClick(View v) { setTorchMode(!mTorchMode); } }); mReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { boolean useTorch = intent.getBooleanExtra("TORCH", false); boolean shouldTakePicture = intent.getBooleanExtra("PICTURE", false); setTorchMode(useTorch); setTakePicture(shouldTakePicture); } }; ct.registerReceiver(mReceiver, new IntentFilter(EyesView.EYES_COMMAND)); mFrame = (FrameLayout) ct.findViewById(R.id.eyes_frame); mImageView = new ImageView(ct); mImageView.setScaleType(ScaleType.FIT_CENTER); mImageView.setBackgroundColor(Color.BLACK); setPersona(PERSONA_READY); mFrame.addView(mImageView); }
From source file:com.rockerhieu.emojicon.slidingTab.SlidingTabLayout.java
/** * This method was custom added by Ivan, based on the post from * http://stackoverflow.com/questions/28125794/slidingtablayout-with-icons-only/28134763#28134763 * @param context//from ww w . ja va 2s. c om * @return */ protected ImageView createDefaultImageView(Context context) { ImageView imageView = new ImageView(context); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); imageView.setPadding(padding, padding, padding, padding); int width = (int) (getResources().getDisplayMetrics().widthPixels / mViewPager.getAdapter().getCount()); imageView.setMinimumWidth(width); return imageView; }