/** * Controls how the image should be resized or moved to match the size of this ImageView. * * @param scaleType The desired scaling mode. * @attr ref android.R.styleable#ImageView_scaleType */ @Override public void setScaleType(ScaleType scaleType) { assert scaleType != null; if (mScaleType != scaleType) { mScaleType = scaleType; switch (scaleType) { case CENTER: case CENTER_CROP: case CENTER_INSIDE: case FIT_CENTER: case FIT_START: case FIT_END: case FIT_XY: super.setScaleType(ScaleType.FIT_XY); break; default: super.setScaleType(scaleType); break; } updateDrawableAttrs(); updateBackgroundDrawableAttrs(false); invalidate(); } }
@Override public void onViewCreated(View view, Bundle onSavedInstanceState) { super.onViewCreated(view, onSavedInstanceState); jpg = (ImageView) getView().findViewById(R.id.imageView3); cal1000(); cal1200(); cal1500(); cal1800(); Bundle bundle = getArguments(); if (bundle != null) buttonPushed = bundle.getInt("button"); if (buttonPushed > 1) { if (buttonPushed == 1000) { jpg.setImageResource(R.drawable.image1000); jpg.setScaleType(ImageView.ScaleType.FIT_END); } else if (buttonPushed == 1200) { jpg.setImageResource(R.drawable.image1200); jpg.setScaleType(ImageView.ScaleType.FIT_END); } else if (buttonPushed == 1500) { jpg.setImageResource(R.drawable.image1500); jpg.setScaleType(ImageView.ScaleType.FIT_END); } else if (buttonPushed == 1800) { jpg.setImageResource(R.drawable.image1800); jpg.setScaleType(ImageView.ScaleType.FIT_END); } } }
/** * Constructor * * @param parent the container view of this one * @param tabId drawable for the tab * @param barId drawable for the bar * @param targetId drawable for the target */ Slider(ViewGroup parent, int tabId, int barId, int targetId) { // Create tab tab = new ImageView(parent.getContext()); tab.setBackgroundResource(tabId); tab.setScaleType(ScaleType.CENTER); tab.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); // Create hint TextView text = new TextView(parent.getContext()); text.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); text.setBackgroundResource(barId); text.setTextAppearance(parent.getContext(), R.style.TextAppearance_SlidingTabNormal); // hint.setSingleLine(); // Hmm.. this causes the text to disappear off-screen // Create target target = new ImageView(parent.getContext()); target.setImageResource(targetId); target.setScaleType(ScaleType.CENTER); target.setLayoutParams( new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); target.setVisibility(View.INVISIBLE); parent.addView(target); // this needs to be first - relies on painter's algorithm parent.addView(tab); parent.addView(text); }
@Override protected void initView() { initialize(); initTitleGone(); guideViews = new ArrayList<View>(); ImageView iv1 = new ImageView(this); iv1.setScaleType(ImageView.ScaleType.FIT_XY); iv1.setImageResource(R.mipmap.p_guide_one); ImageView iv2 = new ImageView(this); iv2.setScaleType(ImageView.ScaleType.FIT_XY); iv2.setImageResource(R.mipmap.p_guide_two); ImageView iv3 = new ImageView(this); iv3.setScaleType(ImageView.ScaleType.FIT_XY); iv3.setImageResource(R.mipmap.p_guide_three); iv3.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { toActivity(PMainActivity.class); PGuideActivity.this.finish(); } }); guideViews.add(iv1); guideViews.add(iv2); guideViews.add(iv3); basePagerAdapter = new BasePagerAdapter(guideViews, this); viewPager.setAdapter(basePagerAdapter); }
public static float[] getBitmapConfiguration( Bitmap bitmap, ImageView imageView, float screenRadio) { int screenWidth = ActivityUtil.getScreenSize()[0]; float rawWidth = 0; float rawHeight = 0; float width = 0; float height = 0; if (bitmap == null) { // rawWidth = sourceWidth; // rawHeight = sourceHeigth; width = (float) (screenWidth / screenRadio); height = (float) width; imageView.setScaleType(ScaleType.FIT_XY); } else { rawWidth = bitmap.getWidth(); rawHeight = bitmap.getHeight(); if (rawHeight > 10 * rawWidth) { imageView.setScaleType(ScaleType.CENTER); } else { imageView.setScaleType(ScaleType.FIT_XY); } float radio = rawHeight / rawWidth; width = (float) (screenWidth / screenRadio); height = (float) (radio * width); } return new float[] {width, height}; }
@SuppressLint("NewApi") protected void onPostExecute(Bitmap image) { if (image != null) { imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setImageBitmap(image); } else { imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setImageResource(R.drawable.ic_failed); } }
@Override public View getView(final int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { imageView = new ImageView(PicContainerActivity.this); imageView.setLayoutParams( new GridView.LayoutParams(IMAGE_VIEW_WIDTH, IMAGE_VIEW_WIDTH)); // imageView.setAdjustViewBounds(false); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(8, 8, 8, 8); } else { imageView = (ImageView) convertView; } if (!readonly && position == imageFileUriList.size()) { imageView.setImageResource(R.drawable.add_camera); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { showPopupWindow(v); } }); } else { final FileEntity image = (FileEntity) this.getItem(position); imageView.setBackgroundResource(0); if (image.getFileUri() != null) { imageView.setImageBitmap( FileHelper.decodeFile(image.getFileUri(), true, IMAGE_VIEW_WIDTH, IMAGE_VIEW_WIDTH)); } else { ImageLoader.getInstance().displayImage(image.getAliasName(), imageView, true); } imageView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(PicContainerActivity.this, ImagePreviewActivity.class); intent.putExtra(ImagePreviewActivity.IMAGE_SRC_KEY, image); intent.putExtra(ImagePreviewActivity.IMAGE_INDEX_IN_CONTAINER, position); intent.putExtra(ImagePreviewActivity.IMAGE_DELETE_FLAG, !readonly); PicContainerActivity.this.startActivityForResult( intent, PREVIEW_IMAGE_ACTIVITY_REQUEST_CODE); } }); } return imageView; }
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); // requestCode對應到startActivityForResult(arg1, arg2)第2個參數 // resultCode是指對方回傳setResult(RESULT_OK,i)第一個值 // data指對方回傳setResult(RESULT_OK,i)第二個值 if (data == null) { System.out.println("data is null"); } if (requestCode == PHOTO_RESULT_CODE) { Bundle bundle = null; if (data != null && (bundle = data.getExtras()) != null) { // 檔案名稱 String photoName = bundle.getString("photoName"); Log.v(TAG, "photoName: " + photoName); String fileSeparator = System.getProperty("file.separator"); File file = new File( Environment.getExternalStorageDirectory().getPath() + fileSeparator + Environment.DIRECTORY_PICTURES, photoName); // 若檔案存在 if (file.exists()) { // decodeFile將文件轉化為Bitmap物件 Bitmap bitmap = BitmapFactory.decodeFile(file.getPath()); // 圖片的顯示方式,xy適當位置 int num = Integer.parseInt("" + photoName.charAt(photoName.indexOf(".") - 1)); switch (num) { // 以photoName尾端數字來判斷哪個按鍵觸發 case 1: mImageView1.setScaleType(ImageView.ScaleType.FIT_XY); mImageView1.setImageBitmap(bitmap); break; case 2: mImageView2.setScaleType(ImageView.ScaleType.FIT_XY); mImageView2.setImageBitmap(bitmap); break; case 3: mImageView3.setScaleType(ImageView.ScaleType.FIT_XY); mImageView3.setImageBitmap(bitmap); break; } } else { Toast.makeText(this.getActivity(), "�ɮפ��s�b", Toast.LENGTH_SHORT).show(); } } } }
@Override public View getView(final int position, View view, ViewGroup parent) { if (view == null) view = getLayoutInflater().inflate(R.layout.list_single, null, false); final ElementManager currentElement = elementsList.get(position); TableRow tableRow = (TableRow) view.findViewById(R.id.tablerow); tableRow.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Bundle bundle = new Bundle(); bundle.putInt("advertid", currentElement.getId()); Intent detail = new Intent(IlanAraActivity.this, IlanActivity.class); detail.putExtras(bundle); startActivity(detail); } }); TextView section = (TextView) view.findViewById(R.id.section); TextView location = (TextView) view.findViewById(R.id.location); TextView price = (TextView) view.findViewById(R.id.price); section.setText(currentElement.getBaslik()); location.setText(currentElement.getKonum()); price.setText(currentElement.getFiyat()); ImageView img = (ImageView) view.findViewById(R.id.img); Basic b = new Basic(); Bitmap map = b.decompressImage(currentElement.getResim()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setImageBitmap(map); return view; }
/** * @brief resetView method * @param v * @detail This method is called when the reset button is clicked and will reset the pictures is * zoomed in/out or rotated left/right */ public void resetView(View v) { ImageView view = (ImageView) v; matrix = new Matrix(); view.setScaleType(ImageView.ScaleType.MATRIX); view.setImageMatrix(matrix); }
private void ask() { Random random = new Random(); for (int i = 0; i < number.length; i++) { number[i] = random.nextInt(5); } int result = number[0] - number[1]; if (result > 0) { key = 0; } else if (result < 0) { key = 2; } else { key = 1; } txtCmpCompare.setText(""); for (int i = 0; i < number.length; i++) { lnrCmpPool[i].removeAllViews(); for (int j = 0; j < number[i]; j++) { ImageView imageView = new ImageView(this); // imageView.setImageResource(R.drawable.ic_launcher); imageView.setImageBitmap(Gfx.getPoke()); imageView.setScaleType(ScaleType.FIT_XY); int size = (int) (50 * Gfx.srcDensity); imageView.setLayoutParams(new LayoutParams(size, size)); lnrCmpPool[i].addView(imageView); } } pivot = random.nextInt(2); txtCmpNumber[pivot].setText(""); txtCmpNumber[1 - pivot].setText(number[1 - pivot] + ""); }
protected void onCreate(Bundle bundle) { super.onCreate(bundle); this.initial_bundle = bundle; ImageView iv = new ImageView(this); iv.setImageResource(R.drawable.monoandroidsplash); iv.setScaleType(ImageView.ScaleType.FIT_CENTER); ViewGroup.LayoutParams ivparams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); setContentView(iv); task = new TimerTask() { @Override public void run() { finish(); Intent intent = new Intent( TrialSplashScreena7bc92805018446e8aa51dc66ad90764.this, vvchart.droid.MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }; new Timer().schedule(task, 3000); }
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView image = new ImageView(SpecificDecoration.this); // image.setImageResource(slider_posters[position]); Picasso.with(SpecificDecoration.this).load(images.get(position)).into(image); image.setBackgroundResource(R.drawable.venue); image.setScaleType(ImageView.ScaleType.CENTER_CROP); ViewGroup.LayoutParams imageparams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); image.setLayoutParams(imageparams); LinearLayout layout = new LinearLayout(SpecificDecoration.this); layout.setOrientation(LinearLayout.VERTICAL); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); // layout.setBackgroundColor(backgroundcolor[position]); // int sih = R.drawable.slider_images_at_homepage; layout.setBackgroundResource(R.drawable.slider_images_at_homepage); layout.setLayoutParams(layoutParams); layout.addView(image); container.addView(layout); return layout; }
@Override public View getView(int position, View convertView, ViewGroup container) { // ImageView thumbnails ImageView imageView; if (convertView == null) { // if it's not recycled, instantiate and initialize imageView = new RecyclingImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(mImageViewLayoutParams); } else { // Otherwise re-use the converted view imageView = (ImageView) convertView; } // Check the height matches our calculated column width if (imageView.getLayoutParams().height != mItemHeight) { imageView.setLayoutParams(mImageViewLayoutParams); } // Finally load the image asynchronously into the ImageView, this also // takes care of setting a placeholder image while the background thread // runs mImageFetcher.loadImage(getItem(position), imageView); return imageView; }
@Override public View getView(int position, View convertView, ViewGroup container) { // Now handle the main ImageView thumbnails ImageView imageView; if (convertView == null) { // if it's not recycled, instantiate and initialize imageView = new ImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setLayoutParams(mImageViewLayoutParams); } else { // Otherwise re-use the converted view imageView = (ImageView) convertView; } // Check the height matches our calculated column width if (imageView.getLayoutParams().height != mItemHeight) { imageView.setLayoutParams(mImageViewLayoutParams); } // Finally load the image asynchronously into the ImageView, this also takes care of // setting a placeholder image while the background thread runs if (!pics_sources.get(position).contains("null")) mPicasso .load(pics_sources.get(position)) .placeholder(R.drawable.gray) .error(R.drawable.loading_image) .config(MizuuApplication.getBitmapConfig()) .into(imageView); else imageView.setImageResource(R.drawable.loading_image); return imageView; }
public View getView(int i, View view, ViewGroup paramViewGroup) { ImageView imageView = (ImageView) view; if (imageView == null) { imageView = new ImageView(EmojiView.this.getContext()) { public void onMeasure(int paramAnonymousInt1, int paramAnonymousInt2) { setMeasuredDimension( View.MeasureSpec.getSize(paramAnonymousInt1), View.MeasureSpec.getSize(paramAnonymousInt1)); } }; imageView.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onEmojiSelected( EmojiView.this.convert((Long) view.getTag())); } EmojiView.this.addToRecent((Long) view.getTag()); } }); imageView.setBackgroundResource(R.drawable.list_selector); imageView.setScaleType(ImageView.ScaleType.CENTER); } imageView.setImageDrawable(Emoji.getEmojiBigDrawable(data[i])); imageView.setTag(data[i]); return imageView; }
// create a new ImageView for each item referenced by the Adapter public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView; if (convertView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); WindowManager wm = (WindowManager) parent.getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; if (width < 1080) { imageView.setLayoutParams(new GridView.LayoutParams(250, 180)); } else { imageView.setLayoutParams(new GridView.LayoutParams(350, 250)); } imageView.setScaleType(ImageView.ScaleType.FIT_XY); imageView.setPadding(8, 8, 8, 8); } else { imageView = (ImageView) convertView; } imageView.setImageResource(mThumbIds[position]); return imageView; }
@Override public View getContentView(int position, View convertView, ViewGroup parent) { ImageView imageView = (ImageView) convertView; if (imageView == null) { imageView = new ImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } int imageResId; switch (getItem(position) % 5) { case 0: imageResId = R.drawable.img_nature1; break; case 1: imageResId = R.drawable.img_nature2; break; case 2: imageResId = R.drawable.img_nature3; break; case 3: imageResId = R.drawable.img_nature4; break; default: imageResId = R.drawable.img_nature5; } Bitmap bitmap = getBitmapFromMemCache(imageResId); if (bitmap == null) { bitmap = BitmapFactory.decodeResource(mContext.getResources(), imageResId); addBitmapToMemoryCache(imageResId, bitmap); } imageView.setImageBitmap(bitmap); return imageView; }
@Override public Object instantiateItem(ViewGroup container, int position) { Context context = ImageShowActivity.this; int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_medium); ImageLocation imageLocation = imageLocations.get(position); if (imageLocation.isLocal()) { ImageView imageView = new ImageView(context); imageView.setPadding(padding, padding, padding, padding); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageURI(imageLocation.getUri()); container.addView(imageView, 0); return imageView; } else { NetworkImageView imageView = new NetworkImageView(context); imageView.setPadding(padding, padding, padding, padding); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setImageUrl( API_IMAGE_GET + imageLocation.getId(), BaseApplication.baseApplication.mImageLoader); container.addView(imageView, 0); return imageView; } }
private void onAsyncStarted(ImageView iv) { if (m_fail_placeholder != 0) { if (m_fail_scaleType != null) iv.setScaleType(m_fail_scaleType); iv.setImageResource(m_fail_placeholder); } }
private LinearLayout getView(int position, Context context) { LinearLayout ll = new LinearLayout(context); ll.setOrientation(LinearLayout.VERTICAL); int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5); ll.setPadding(dp_5, dp_5, dp_5, dp_5); ImageView iv = new ImageView(context); iv.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(iconWidth, iconWidth); lpIv.gravity = Gravity.CENTER_HORIZONTAL; iv.setLayoutParams(lpIv); iv.setImageBitmap(getIcon(platforms[position])); ll.addView(iv); TextView tv = new TextView(context); tv.setTextColor(0xffffffff); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); tv.setSingleLine(); tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP); LinearLayout.LayoutParams lpTv = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); lpTv.weight = 1; tv.setLayoutParams(lpTv); tv.setText(getName(platforms[position])); ll.addView(tv); return ll; }
@Override protected void onCreate(Bundle state) { super.onCreate(state); setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR); String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT); cameraView = new CameraView(this); cameraBorder = new LinearLayout(this); cameraBorder.setGravity(CENTER); cameraBorder.setBackgroundColor(BLACK); cameraBorder.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f)); cameraBorder.addView(cameraView); ImageView qrCodeView = new ImageView(this); qrCodeView.setScaleType(FIT_CENTER); qrCodeView.setBackgroundColor(WHITE); qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f)); Display display = getWindowManager().getDefaultDisplay(); boolean portrait = display.getWidth() < display.getHeight(); layoutMain = new LinearLayout(this); if (portrait) layoutMain.setOrientation(VERTICAL); else layoutMain.setOrientation(HORIZONTAL); layoutMain.setWeightSum(2); layoutMain.addView(cameraBorder); layoutMain.addView(qrCodeView); setContentView(layoutMain); new QrGenAsyncTask(this, qrCodeView).execute(qrData); }
private void initActionButton() { actionButton = new ImageView(mapActivity); int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size); int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(btnSize, btnSize); int marginRight = btnSize / 4; params.setMargins( 0, landscape ? 0 : topPad - 2 * btnSize, marginRight, landscape ? marginRight : 0); params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT; actionButton.setLayoutParams(params); actionButton.setScaleType(ScaleType.CENTER); actionButton.setImageDrawable( mapActivity.getResources().getDrawable(R.drawable.map_my_location)); actionButton.setBackgroundDrawable( mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue)); hideActionButton(); actionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (getMyApplication().accessibilityEnabled()) { mapActivity.getMapActions().whereAmIDialog(); } else { mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); } hideDashboard(); } }); }
public ZoomImageView(Context context, AttributeSet attrs) { super(context, attrs); super.setScaleType(ScaleType.MATRIX); mGestureDetector = new GestureDetector( context, new SimpleOnGestureListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (isAutoScale == true) return true; float x = e.getX(); float y = e.getY(); Log.e("DoubleTap", getScale() + " , " + initScale); if (getScale() < SCALE_MID) { ZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MID, x, y), 16); isAutoScale = true; } else if (getScale() >= SCALE_MID && getScale() < SCALE_MAX) { ZoomImageView.this.postDelayed(new AutoScaleRunnable(SCALE_MAX, x, y), 16); isAutoScale = true; } else { ZoomImageView.this.postDelayed(new AutoScaleRunnable(initScale, x, y), 16); isAutoScale = true; } return true; } }); mScaleGestureDetector = new ScaleGestureDetector(context, this); this.setOnTouchListener(this); }
private void addIconTabBådeTekstOgBillede( final int position, int resId, Bitmap res, String title) { FrameLayout tabfl = new FrameLayout(getContext()); if (Build.VERSION.SDK_INT > 11) tabfl.setLayoutTransition(new LayoutTransition()); ImageView tabi = new ImageView(getContext()); tabi.setContentDescription(title); if (res != null) { tabi.setImageBitmap(res); tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE); tabi.setAdjustViewBounds(true); } else { tabi.setImageResource(resId); } tabi.setVisibility(View.GONE); TextView tabt = new TextView(getContext()); tabt.setText(title); tabt.setTypeface(App.skrift_gibson); tabt.setGravity(Gravity.CENTER); tabt.setSingleLine(); tabfl.addView(tabi); tabfl.addView(tabt); LayoutParams lp = (LayoutParams) tabi.getLayoutParams(); lp.gravity = Gravity.CENTER; lp = (LayoutParams) tabt.getLayoutParams(); lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT; lp.gravity = Gravity.CENTER; addTab(position, tabfl); }
public AddMemberCell(Context context) { super(context); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.addmember); imageView.setScaleType(ImageView.ScaleType.CENTER); addView( imageView, LayoutHelper.createFrame( 48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 68, 8, LocaleController.isRTL ? 68 : 0, 0)); SimpleTextView textView = new SimpleTextView(context); textView.setTextColor(0xff212121); textView.setTextSize(17); textView.setText(LocaleController.getString("AddMember", R.string.AddMember)); textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); addView( textView, LayoutHelper.createFrame( LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : 129, 22.5f, LocaleController.isRTL ? 129 : 28, 0)); }
private void initialViewComponent() { mImageView1.setScaleType(ImageView.ScaleType.FIT_XY); Bitmap b = getPhoto(tabInfo.getTxtTID() + "_1.jpg"); if (b != null) mImageView1.setImageBitmap(b); else mImageView1.setImageDrawable(getView().getResources().getDrawable(R.drawable.picture)); mImageView2.setScaleType(ImageView.ScaleType.FIT_XY); b = getPhoto(tabInfo.getTxtTID() + "_2.jpg"); if (b != null) mImageView2.setImageBitmap(b); else mImageView2.setImageDrawable(getView().getResources().getDrawable(R.drawable.picture)); mImageView3.setScaleType(ImageView.ScaleType.FIT_XY); b = getPhoto(tabInfo.getTxtTID() + "_3.jpg"); if (b != null) mImageView3.setImageBitmap(b); else mImageView3.setImageDrawable(getView().getResources().getDrawable(R.drawable.picture)); }
private void createCrossImage() { mCrossImage = new ImageView(getContext()); // Dismiss the dialog when user click on the 'x' mCrossImage.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mListener.onCancel(); FbDialog.this.dismiss(); } }); int px30 = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 30, getContext().getResources().getDisplayMetrics()); mCrossImage.setLayoutParams(new FrameLayout.LayoutParams(px30, px30)); mCrossImage.setScaleType(ImageView.ScaleType.FIT_CENTER); byte[] decodedString = Base64.decode(CLOSE_BT, Base64.DEFAULT); Bitmap cross = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); mCrossImage.setImageBitmap(cross); /* 'x' should not be visible while webview is loading * make it visible only after webview has fully loaded */ mCrossImage.setVisibility(View.INVISIBLE); }
/** * 初始化 * * @param context context */ private void init(Context context) { mHeaderContainer = (RelativeLayout) findViewById(R.id.pull_to_refresh_header_content); mArrowImageView = (ImageView) findViewById(R.id.pull_to_refresh_header_arrow); mHintTextView = (TextView) findViewById(R.id.pull_to_refresh_header_hint_textview); mHeaderTimeView = (TextView) findViewById(R.id.pull_to_refresh_header_time); mHeaderTimeViewTitle = (TextView) findViewById(R.id.pull_to_refresh_last_update_time_text); mArrowImageView.setScaleType(ScaleType.CENTER); mArrowImageView.setImageResource(R.drawable.default_ptr_rotate); float pivotValue = 0.5f; // SUPPRESS CHECKSTYLE float toDegree = 720.0f; // SUPPRESS CHECKSTYLE mRotateAnimation = new RotateAnimation( 0.0f, toDegree, Animation.RELATIVE_TO_SELF, pivotValue, Animation.RELATIVE_TO_SELF, pivotValue); mRotateAnimation.setFillAfter(true); mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR); mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION); mRotateAnimation.setRepeatCount(Animation.INFINITE); mRotateAnimation.setRepeatMode(Animation.RESTART); }
public Object instantiateItem(ViewGroup container, final int position) { ImageView image = new ImageView(getContext()); image.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); image.setAdjustViewBounds(false); image.setScaleType(ImageView.ScaleType.FIT_XY); final AQuery aq = new AQuery(image); if (m_mode == MODE.ASYNC) { AQueryHelper qh = new AQueryHelper(aq, image, imagesArray.get(position)) .failDrawable(R.drawable.placeholder_big); qh.loadImage(); } else { InputStream ims = null; try { ims = getResources().getAssets().open(imagesArray.get(position)); } catch (IOException e) { e.printStackTrace(); } // load image as Drawable Drawable d = Drawable.createFromStream(ims, null); // set image to ImageView image.setImageDrawable(d); } container.addView(image, 0); return image; }