Example usage for android.widget ImageView setScaleX

List of usage examples for android.widget ImageView setScaleX

Introduction

In this page you can find the example usage for android.widget ImageView setScaleX.

Prototype

public void setScaleX(float scaleX) 

Source Link

Document

Sets the amount that the view is scaled in x around the pivot point, as a proportion of the view's unscaled width.

Usage

From source file:Main.java

public static void reset(View circleBackground, ImageView icon1, ImageView icon2) {
    icon1.setVisibility(View.GONE);
    icon2.setVisibility(View.VISIBLE);
    icon2.setScaleX(mScaleX);
    icon2.setScaleY(mScaleY);/*from w  ww.  j  a  v a2  s .c o  m*/
}

From source file:Main.java

public static void animatePhotoLike(final ImageView likeBg, final ImageView likeIcon) {
    likeBg.setVisibility(View.VISIBLE);
    likeIcon.setVisibility(View.VISIBLE);

    likeBg.setScaleY(0.1f);//from   w w  w  .  ja v a  2  s.com
    likeBg.setScaleX(0.1f);
    likeBg.setAlpha(1f);
    likeIcon.setScaleY(0.1f);
    likeIcon.setScaleX(0.1f);

    AnimatorSet animatorSet = new AnimatorSet();

    ObjectAnimator bgScaleYAnim = ObjectAnimator.ofFloat(likeBg, "scaleY", 0.1f, 1f);
    bgScaleYAnim.setDuration(200);
    bgScaleYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgScaleXAnim = ObjectAnimator.ofFloat(likeBg, "scaleX", 0.1f, 1f);
    bgScaleXAnim.setDuration(200);
    bgScaleXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator bgAlphaAnim = ObjectAnimator.ofFloat(likeBg, "alpha", 1f, 0f);
    bgAlphaAnim.setDuration(200);
    bgAlphaAnim.setStartDelay(150);
    bgAlphaAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleUpYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 0.1f, 1f);
    imgScaleUpYAnim.setDuration(300);
    imgScaleUpYAnim.setInterpolator(DECCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleUpXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 0.1f, 1f);
    imgScaleUpXAnim.setDuration(300);
    imgScaleUpXAnim.setInterpolator(DECCELERATE_INTERPOLATOR);

    ObjectAnimator imgScaleDownYAnim = ObjectAnimator.ofFloat(likeIcon, "scaleY", 1f, 0f);
    imgScaleDownYAnim.setDuration(300);
    imgScaleDownYAnim.setInterpolator(ACCELERATE_INTERPOLATOR);
    ObjectAnimator imgScaleDownXAnim = ObjectAnimator.ofFloat(likeIcon, "scaleX", 1f, 0f);
    imgScaleDownXAnim.setDuration(300);
    imgScaleDownXAnim.setInterpolator(ACCELERATE_INTERPOLATOR);

    animatorSet.playTogether(bgScaleYAnim, bgScaleXAnim, bgAlphaAnim, imgScaleUpYAnim, imgScaleUpXAnim);
    animatorSet.play(imgScaleDownYAnim).with(imgScaleDownXAnim).after(imgScaleUpYAnim);

    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            resetLikeAnimationState(likeBg, likeIcon);
        }
    });
    animatorSet.start();
}

From source file:com.scigames.slidereview.MenuActivity.java

private void displayProfile() {
    setContentView(R.layout.menu_page);//from www . j a  va2s. c o  m
    Log.d(TAG, "...setContentView");

    //display name and profile info
    Resources res = getResources();
    greets = (TextView) findViewById(R.id.student_name);
    greets.setText(String.format(res.getString(R.string.profile_name), firstNameIn, lastNameIn));
    setTextViewFont(Museo700Regular, greets);
    Log.d(TAG, "...Profile Info");

    reviewBtn = (Button) findViewById(R.id.btn_review);
    reviewBtn.setOnClickListener(mReview);
    setButtonFont(ExistenceLightOtf, reviewBtn);

    infoDialog = new AlertDialog.Builder(MenuActivity.this).create();
    infoDialog.setTitle("Debug Info");
    infoDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
        }
    });

    if (debug) {
        //      infoDialog.setTitle("studentId");
        //      infoDialog.setMessage(studentIdIn);
        //      infoDialog.show();
    }

    task.setOnResultsListener(this);
    task.cancel(true);
    task = new SciGamesHttpPoster(MenuActivity.this, baseDbURL + "/pull/return_profile.php");
    task.setOnResultsListener(MenuActivity.this);

    //download photo
    ImageView profilePhoto = (ImageView) findViewById(R.id.profile_image);
    profilePhoto.setTag(photoUrl);
    profilePhoto.setScaleX(1.4f);
    profilePhoto.setScaleY(1.4f);
    profilePhoto.setX(120f);
    profilePhoto.setY(123f);
    photoTask.cancel(true);
    photoTask = new DownloadProfilePhoto(MenuActivity.this, photoUrl);
    //AsyncTask<ImageView, Void, Bitmap> pPhoto = 
    photoTask.execute(profilePhoto);
}

From source file:com.scigames.slidegame.MenuActivity.java

private void displayProfile() {
    setContentView(R.layout.menu_page);/*from w w  w .  j  av  a 2 s.  c  o m*/
    Log.d(TAG, "...setContentView");

    //display name and profile info
    Resources res = getResources();
    greets = (TextView) findViewById(R.id.student_name);
    greets.setText(String.format(res.getString(R.string.profile_name), firstNameIn, lastNameIn));
    setTextViewFont(Museo700Regular, greets);
    Log.d(TAG, "...Profile Info");

    playBtn = (Button) findViewById(R.id.btn_play);
    playBtn.setOnClickListener(mPlay);
    setButtonFont(ExistenceLightOtf, playBtn);

    infoDialog = new AlertDialog.Builder(MenuActivity.this).create();
    infoDialog.setTitle("Debug Info");
    infoDialog.setButton(RESULT_OK, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog closed
        }
    });

    if (debug) {
        //      infoDialog.setTitle("studentId");
        //      infoDialog.setMessage(studentIdIn);
        //      infoDialog.show();
    }

    task.setOnResultsListener(this);
    task.cancel(true);
    task = new SciGamesHttpPoster(MenuActivity.this, baseDbURL + "/pull/return_profile.php");
    task.setOnResultsListener(MenuActivity.this);

    //download photo
    ImageView profilePhoto = (ImageView) findViewById(R.id.profile_image);
    profilePhoto.setTag(photoUrl);
    profilePhoto.setScaleX(1.4f);
    profilePhoto.setScaleY(1.4f);
    profilePhoto.setX(120f);
    profilePhoto.setY(123f);
    photoTask.cancel(true);
    photoTask = new DownloadProfilePhoto(MenuActivity.this, photoUrl);
    //AsyncTask<ImageView, Void, Bitmap> pPhoto = 
    photoTask.execute(profilePhoto);
}

From source file:com.icenler.lib.view.LivingTabsLayout.java

@Override
public void setupWithViewPager(@NonNull ViewPager viewPager) {
    final PagerAdapter adapter = viewPager.getAdapter();

    DrawableResIconAdapter drawableResIconAdapter = null;
    DrawableIconAdapter drawableIconAdapter = null;

    boolean isDrawableResAdapter;
    if ((isDrawableResAdapter = adapter instanceof DrawableResIconAdapter)) {
        drawableResIconAdapter = (DrawableResIconAdapter) adapter;
    } else if (adapter instanceof DrawableIconAdapter) {
        drawableIconAdapter = (DrawableIconAdapter) adapter;
    } else {//from w  w  w .j av  a  2 s.co  m
        throw new IllegalArgumentException(
                "ViewPager's adapter must implement either DrawableIconAdapter or DrawableResIconAdapter");
    }
    super.setupWithViewPager(viewPager);

    final int selectedTabPosition = getSelectedTabPosition();
    final int count = adapter.getCount();
    if (tabs == null)
        tabs = new ArrayList<>(count);
    else {
        tabs.clear();
    }
    for (int i = 0; i < count; ++i) {
        Tab t = super.getTabAt(i);
        if (isDrawableResAdapter)
            t.setIcon(drawableResIconAdapter.getIcon(i));
        else
            t.setIcon(drawableIconAdapter.getIcon(i));
        final LivingTab tab = newLivingTab(t);
        //  .setText(adapter.getPageTitle(i))
        //.setIcon(icons.get(i));
        addTab(tab);

        if (i != selectedTabPosition) {
            final TextView textView = tab.textView;
            textView.setScaleY(SCALE_HIDDEN);
            textView.setScaleX(SCALE_HIDDEN);
        } else {
            final ImageView iconView = tab.iconView;
            iconView.setScaleY(SCALE_HIDDEN);
            iconView.setScaleX(SCALE_HIDDEN);
        }
    }

    viewPager.addOnPageChangeListener(new LivingTabsOnPageChangeListener(this));
}

From source file:com.github.saiff35.livingtabs.LivingTabsLayout.java

@Override
public void setupWithViewPager(@NonNull ViewPager viewPager) {

    final PagerAdapter adapter = viewPager.getAdapter();
    DrawableResIconAdapter drawableResIconAdapter = null;
    DrawableIconAdapter drawableIconAdapter = null;
    boolean isDrawableResAdapter;
    if ((isDrawableResAdapter = adapter instanceof DrawableResIconAdapter)) {
        drawableResIconAdapter = (DrawableResIconAdapter) adapter;
    } else if (adapter instanceof DrawableIconAdapter) {
        drawableIconAdapter = (DrawableIconAdapter) adapter;
    } else {/*from   ww  w . j  ava 2  s .  c om*/
        throw new IllegalArgumentException(
                "ViewPager's adapter must implement either DrawableIconAdapter or DrawableResIconAdapter");
    }
    super.setupWithViewPager(viewPager);

    final int selectedTabPosition = getSelectedTabPosition();
    final int count = adapter.getCount();
    if (tabs == null)
        tabs = new ArrayList<>(count);
    else {
        tabs.clear();
    }
    for (int i = 0; i < count; ++i) {
        Tab t = super.getTabAt(i);
        if (isDrawableResAdapter)
            t.setIcon(drawableResIconAdapter.getIcon(i));
        else
            t.setIcon(drawableIconAdapter.getIcon(i));
        final LivingTab tab = newLivingTab(t);
        //  .setText(adapter.getPageTitle(i))
        //.setIcon(icons.get(i));
        addTab(tab);

        if (i != selectedTabPosition) {
            final TextView textView = tab.textView;
            textView.setScaleY(SCALE_HIDDEN);
            textView.setScaleX(SCALE_HIDDEN);
        } else {
            final ImageView iconView = tab.iconView;
            iconView.setScaleY(SCALE_HIDDEN);
            iconView.setScaleX(SCALE_HIDDEN);
        }
    }

    viewPager.addOnPageChangeListener(new LivingTabsOnPageChangeListener(this));
}

From source file:com.icenler.lib.view.LivingTabsLayout.java

private void setScalePosition(final int position, final float positionOffset, final int oldPosition,
        final int pendingPosition) {
    if (!animationRunning) {
        int newPosition = position;

        float scale = positionOffset;
        if (position == oldPosition) {
            //TODO solve out of bound
            newPosition = position + 1;/*from w  w w .ja  va 2 s  .c  o m*/
        } else {
            scale = 1 - scale;
        }

        if (pendingPosition != -1) {
            newPosition = pendingPosition;
        }

        final LivingTab newTab = tabs.get(newPosition);
        TextView newTv = newTab.textView;

        newTv.setScaleY(scale);
        newTv.setScaleX(scale);
        ImageView newIv = newTab.iconView;
        float inversedScale = 1 - scale;
        newIv.setScaleY(inversedScale);
        newIv.setScaleX(inversedScale);

        final LivingTab oldTab = tabs.get(oldPosition);
        TextView oldTv = oldTab.textView;
        oldTv.setScaleY(inversedScale);
        oldTv.setScaleX(inversedScale);
        ImageView oldIv = oldTab.iconView;
        oldIv.setScaleY(scale);
        oldIv.setScaleX(scale);
    }
}

From source file:com.lcc.view.LivingTabsLayout.java

private void setScalePosition(final int position, final float positionOffset, final int oldPosition,
        final int pendingPosition) {
    if (!animationRunning) {
        int newPosition = position;

        float scale = positionOffset;
        if (position == oldPosition) {
            newPosition = position + 1;//from   ww w .  ja  va 2  s  .  c o m
        } else {
            scale = 1 - scale;
        }
        if (pendingPosition != -1) {
            newPosition = pendingPosition;

        }

        final LivingTab newTab = tabs.get(newPosition);
        TextView newTv = newTab.textView;

        newTv.setScaleY(scale);
        newTv.setScaleX(scale);
        ImageView newIv = newTab.iconView;
        float inversedScale = 1 - scale;
        newIv.setScaleY(inversedScale);
        newIv.setScaleX(inversedScale);

        final LivingTab oldTab = tabs.get(oldPosition);
        TextView oldTv = oldTab.textView;
        oldTv.setScaleY(inversedScale);
        oldTv.setScaleX(inversedScale);
        ImageView oldIv = oldTab.iconView;
        oldIv.setScaleY(scale);
        oldIv.setScaleX(scale);
    }
}

From source file:com.github.saiff35.livingtabs.LivingTabsLayout.java

private void setScalePosition(final int position, final float positionOffset, final int oldPosition,
        final int pendingPosition) {
    if (!animationRunning) {
        int newPosition = position;

        float scale = positionOffset;
        if (position == oldPosition) {
            //TODO solve out of bound
            newPosition = position + 1;/*from   ww  w. j av  a2  s.c o  m*/

        } else {
            scale = 1 - scale;
        }
        if (pendingPosition != -1) {
            newPosition = pendingPosition;

        }
        final LivingTab newTab = tabs.get(newPosition);
        TextView newTv = newTab.textView;

        newTv.setScaleY(scale);
        newTv.setScaleX(scale);
        ImageView newIv = newTab.iconView;
        float inversedScale = 1 - scale;
        newIv.setScaleY(inversedScale);
        newIv.setScaleX(inversedScale);

        final LivingTab oldTab = tabs.get(oldPosition);
        TextView oldTv = oldTab.textView;
        oldTv.setScaleY(inversedScale);
        oldTv.setScaleX(inversedScale);
        ImageView oldIv = oldTab.iconView;
        oldIv.setScaleY(scale);
        oldIv.setScaleX(scale);
    }
}

From source file:com.woofer.activity.personHomeActivity.java

public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.LEFT;
    layoutParams.leftMargin = 30;/*from   w  w  w  .  ja  va  2  s  .  c  om*/
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {

        TableRow tableRow = new TableRow(this);
        TextView textView7 = new TextView(this);
        textView7.setText("" + i);
        textView7.setTextSize(18);
        textView7.setTextColor(Color.rgb(0, 0, 0));

        textView7.setPadding(15, 0, 15, 0);
        tableRow.addView(textView7, layoutParams);
        tableRow.setBackgroundColor(Color.WHITE);

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);

        TableRow tableRow1 = new TableRow(this);
        TextView textView1 = new TextView(this);
        textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i);
        textView1.setTextSize(16);
        textView1.setPadding(15, 0, 15, 15);
        tableRow1.addView(textView1, layoutParams);
        tableRow1.setBackgroundColor(Color.WHITE);

        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });
        mMainLayout.addView(tableRow1);

        //            TableRow tableRow2 = new TableRow(this);
        //            //tableRow2.addView(textView2, layoutParams);
        //            ImageView imageView = new ImageView(this);
        //            imageView.setImageResource(R.drawable.icon_reply_t);
        //            imageView.setScaleX((float) a);
        //            imageView.setScaleY((float) a);
        //            imageView.setPadding(0, 0, 0, 0);
        //
        //            ImageView imageView1 = new ImageView(this);
        //            imageView1.setImageResource(R.drawable.icon_thumb_t);
        //            imageView1.setScaleX((float) a);
        //            imageView1.setScaleY((float) a);
        //            imageView1.setPadding(0, 0, 0, 0);
        //
        //
        //            //tableRow2.addView(imageView);
        //            tableRow2.addView(imageView1);
        //            mMainLayout.addView(tableRow2);
        TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL);
        int numberOfRow = 1;
        int numberOfColumn = 12;
        int cellDimension = 24;
        int cellPadding = 200;
        for (int row = 0; row < numberOfRow; row++) {
            tableRow = new TableRow(this);
            //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
            tableRow.setLayoutParams(new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));

            for (int column = 0; column < numberOfColumn; column++) {
                if (column % 3 == 0) {
                    TextView textView = new TextView(this);
                    textView.setTextSize(20);
                    textView.setText("   ");
                    tableRow.addView(textView);
                }
                if (column % 3 == 1) {
                    if (column == 1) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_eye_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 4) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_thumb_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 7) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_reply_t);
                        tableRow.addView(imageView);
                    }
                    if (column == 10) {
                        ImageView imageView = new ImageView(this);
                        imageView.setScaleX((float) 0.5);
                        imageView.setScaleY((float) 0.5);
                        imageView.setImageResource(R.drawable.icon_pencil_t);
                        tableRow.addView(imageView);
                    }
                }
                if (column % 3 == 2) {
                    if (column == 2) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 5) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 8) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                    if (column == 11) {
                        TextView textView = new TextView(this);
                        textView.setText("8");
                        tableRow.addView(textView);
                    }
                }

            }
            mytable.addView(tableRow, new TableLayout.LayoutParams(
                    (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding));
            //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT));
        }

    }
}