List of usage examples for android.widget ImageView getLayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") public ViewGroup.LayoutParams getLayoutParams()
From source file:com.android.inputmethod.keyboard.EmojiLayoutParams.java
public void setKeyProperties(ImageView ib) { final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib.getLayoutParams(); lp.leftMargin = mKeyHorizontalGap / 2; lp.rightMargin = mKeyHorizontalGap / 2; ib.setLayoutParams(lp);// ww w. j av a 2 s . co m }
From source file:com.tigerpenguin.places.model.Photo.java
public void loadImage(Context context, ImageView imageView) { int width = imageView.getLayoutParams().width; if (width <= 0) { width = imageView.getMeasuredWidth(); }/*from w w w .j ava2 s .com*/ int height = imageView.getLayoutParams().height; if (height <= 0) { height = imageView.getMeasuredHeight(); } Picasso.with(context).load(getUrl(context, width, height)).into(imageView); }
From source file:com.openlocationcode.android.main.WelcomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Second argument is the default to use if the preference can't be found int savedVersionCode = prefs.getInt(WELCOME_VERSION_CODE_SHOWN_PREF, 0); int appVersionCode = 0; try {// w ww . j av a 2 s .c om appVersionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; } catch (NameNotFoundException nnfe) { Log.w(TAG, "Exception getting appVersionCode : " + nnfe); } final Intent intent = new Intent(this, MainActivity.class); final Activity activity = this; if (appVersionCode == savedVersionCode) { activity.startActivity(intent); activity.finish(); } else { Log.i(TAG, "Starting welcome page"); setContentView(R.layout.welcome); // Increase the margin on the image to account for the translucent status bar. ImageView welcomeImage = (ImageView) findViewById(R.id.welcome_image); LayoutParams layoutParams = (LayoutParams) welcomeImage.getLayoutParams(); layoutParams.topMargin = layoutParams.topMargin + MainActivity.getStatusBarHeight(this); welcomeImage.setLayoutParams(layoutParams); Button button = (Button) findViewById(R.id.welcome_button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { activity.startActivity(intent); activity.finish(); } }); SharedPreferences.Editor editor = prefs.edit(); editor.putInt(WELCOME_VERSION_CODE_SHOWN_PREF, appVersionCode); editor.apply(); } }
From source file:be.ac.ucl.lfsab1509.bouboule.MyLevelFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.myfragment_layout, container, false); /* Set the locks and co */ if (mCurrentPage <= lastUnlockedWorld) { ((ImageView) v.findViewById(R.id.levelimage)).setImageResource((getResources() .getIdentifier("world" + mCurrentPage, "drawable", getActivity().getPackageName()))); // or (R.drawable.world1 + mCurrentPage - 1) but maybe dangerous /* Hack to set the right size on small devices */ ImageView imageLvl = (ImageView) v.findViewById(R.id.levelimage); LayoutParams params = (LayoutParams) imageLvl.getLayoutParams(); params.width = getDisplayVector().x / 2; imageLvl.setLayoutParams(params); ImageButton play = (ImageButton) v.findViewById(R.id.play); /* Activate the play and desactivate the lock */ play.setOnClickListener(clickListener); ImageButton lock = (ImageButton) v.findViewById(R.id.lock); lock.setVisibility(View.INVISIBLE); } else {//w w w .j av a2 s . c o m ImageButton play = (ImageButton) v.findViewById(R.id.play); play.setVisibility(View.INVISIBLE); //imageLvl.setColorFilter(new LightingColorFilter(Color.GRAY, 1)); } return v; }
From source file:com.vuw.project1.riverwatch.Report_functionality.ReportInfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_report_info, container, false); description = (EditText) rootView.findViewById(R.id.submission_details_description); extraDetails = (EditText) rootView.findViewById(R.id.submission_details_extra_details); submitButton = (Button) rootView.findViewById(R.id.submit_button); submitButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww . j a v a 2 s .c om public void onClick(View v) { submit(); } }); imagePath = getArguments().getString("ImagePath"); if (imagePath != null && !imagePath.equals("")) { final ImageView imageView = (ImageView) rootView.findViewById(R.id.submission_details_photo); float imgWeight = ((LinearLayout.LayoutParams) (imageView.getLayoutParams())).weight; ScreenDimensions dimensioner = new ScreenDimensions(getActivity().getBaseContext()); int imgHeight = (int) (dimensioner.getScreenHeight() * imgWeight); imageView.setImageBitmap(BitMapDisplay.decodeSampledBitmapFromPath(imagePath, imgHeight)); } else { rootView.findViewById(R.id.submission_details_photo).setVisibility(View.GONE); } return rootView; }
From source file:org.openmrs.mobile.activities.dashboard.DashboardFragment.java
/** * Binds drawable resource to ImageView/*from ww w .j a va2s . com*/ * @param imageView ImageView to bind resource to * @param drawableId id of drawable resource (for example R.id.somePicture); */ private void bindDrawableResource(ImageView imageView, int drawableId) { mBitmapCache = new SparseArray<>(); if (getView() != null) { createImageBitmap(drawableId, imageView.getLayoutParams()); imageView.setImageBitmap(mBitmapCache.get(drawableId)); } }
From source file:com.example.PagerCoverFlow.PagerContainer.java
private void transformImageBitmap(ImageView child, Matrix imageMatrix, int rotationAngle) { mCamera.save();/*from w w w.j ava2 s .c o m*/ // final Matrix imageMatrix = t.getMatrix();; final int imageHeight = child.getLayoutParams().height; final int imageWidth = child.getLayoutParams().width; final int rotation = Math.abs(rotationAngle); // mCamera.translate(0.0f, 0.0f, 100.0f); Log.i("Select", "imageWidth:" + imageWidth + " " + "imageHeight:" + imageHeight); //As the angle of the view gets less, zoom in // if ( rotation < mMaxRotationAngle ) { float zoomAmount = (float) (mMaxZoom + (rotation * 1.5)); Log.i("Select", "rotation:" + rotation + " zoomAmount:" + zoomAmount); mCamera.translate(0.0f, 0.0f, zoomAmount); } //Alpha int alphaVal = 255 - rotation * 3; // child.setAlpha(alphaVal); //[0,255] child.getDrawable().setAlpha(alphaVal); // mCamera.rotateY(rotationAngle); mCamera.getMatrix(imageMatrix); imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2)); imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2)); mCamera.restore(); float[] values = new float[9]; imageMatrix.getValues(values); float globalX = values[Matrix.MTRANS_X]; float globalY = values[Matrix.MTRANS_Y]; // float width = values[Matrix.MSCALE_X]*CommonValue.menuWidth ; // float height = values[Matrix.MSCALE_Y]*CommonValue.menuWidth; values[Matrix.MSCALE_X] = 2; values[Matrix.MSCALE_Y] = 2; imageMatrix.setValues(values); }
From source file:id.ridon.keude.views.AppListAdapter.java
private void layoutIcon(ImageView icon, boolean compact) { int size = (int) mContext.getResources() .getDimension((compact ? R.dimen.applist_icon_compact_size : R.dimen.applist_icon_normal_size)); LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) icon.getLayoutParams(); params.height = size;//from w w w . ja v a2 s . c om params.width = size; icon.setLayoutParams(params); }
From source file:Main.java
public static void scaleImage(ImageView view, int boundBoxInDp) { // Get the ImageView and its bitmap Drawable drawing = view.getDrawable(); Bitmap bitmap = ((BitmapDrawable) drawing).getBitmap(); // Get current dimensions int width = bitmap.getWidth(); int height = bitmap.getHeight(); // Determine how much to scale: the dimension requiring less scaling is // closer to the its side. This way the image always stays inside your // bounding box AND either x/y axis touches it. float xScale = ((float) boundBoxInDp) / width; float yScale = ((float) boundBoxInDp) / height; float scale = (xScale <= yScale) ? xScale : yScale; // Create a matrix for the scaling and add the scaling data Matrix matrix = new Matrix(); matrix.postScale(scale, scale);//w ww . ja v a2s .com // Create a new bitmap and convert it to a format understood by the ImageView Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); BitmapDrawable result = new BitmapDrawable(scaledBitmap); width = scaledBitmap.getWidth(); height = scaledBitmap.getHeight(); // Apply the scaled bitmap view.setImageDrawable(result); // Now change ImageView's dimensions to match the scaled image LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.width = width; params.height = height; view.setLayoutParams(params); }
From source file:Main.java
public static void scaleImageWithOriRatio(ImageView view, int boundBoxInDp) { // Get the ImageView and its bitmap Drawable drawing = view.getDrawable(); Bitmap bitmap = ((BitmapDrawable) drawing).getBitmap(); // Get current dimensions int width = bitmap.getWidth(); int height = bitmap.getHeight(); // Determine how much to scale: the dimension requiring less scaling is // closer to the its side. This way the image always stays inside your // bounding box AND either x/y axis touches it. float xScale = ((float) boundBoxInDp) / width; float yScale = ((float) boundBoxInDp) / height; float scale = (xScale <= yScale) ? xScale : yScale; // Create a matrix for the scaling and add the scaling data Matrix matrix = new Matrix(); matrix.postScale(scale, scale);// w w w . j av a 2 s .c o m // Create a new bitmap and convert it to a format understood by the // ImageView Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); BitmapDrawable result = new BitmapDrawable(scaledBitmap); width = scaledBitmap.getWidth(); height = scaledBitmap.getHeight(); // Apply the scaled bitmap view.setImageDrawable(result); // Now change ImageView's dimensions to match the scaled image LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams(); params.width = width; params.height = height; view.setLayoutParams(params); }