Example usage for android.view View getWidth

List of usage examples for android.view View getWidth

Introduction

In this page you can find the example usage for android.view View getWidth.

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

Usage

From source file:com.birdgang.viewpagerheader.indicator.SpringIndicator.java

private void createPoints() {
    if (null == viewPager || (null == tabs || tabs.size() <= 0)) {
        return;//from  w ww  . j ava 2 s  .c  o  m
    }

    View view = tabs.get(viewPager.getCurrentItem());
    float headX = view.getX() + view.getWidth() / 2;
    float headY = view.getY() + view.getHeight() / 2;
    float footX = view.getX() + view.getWidth() / 2;
    float footY = view.getY() + view.getHeight() / 2;

    springView.getHeadPoint().setX(headX);
    springView.getHeadPoint().setY(headY);
    springView.getFootPoint().setX(footX);
    springView.getFootPoint().setY(footY);
    springView.animCreate();
}

From source file:android.support.transition.ChangeClipBounds.java

private void captureValues(TransitionValues values) {
    View view = values.view;
    if (view.getVisibility() == View.GONE) {
        return;/*from  ww  w .  j  av a 2  s .  co m*/
    }

    Rect clip = ViewCompat.getClipBounds(view);
    values.values.put(PROPNAME_CLIP, clip);
    if (clip == null) {
        Rect bounds = new Rect(0, 0, view.getWidth(), view.getHeight());
        values.values.put(PROPNAME_BOUNDS, bounds);
    }
}

From source file:com.example.android.saddacampus.MainActivity.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public void circleReveal(int viewID, int posFromRight, boolean containsOverflow, final boolean isShow) {
    final View myView = findViewById(viewID);

    int width = myView.getWidth();

    if (posFromRight > 0)
        width -= (posFromRight//from w ww .j av a  2 s.c o  m
                * getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_material))
                - (getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_material) / 2);
    if (containsOverflow)
        width -= getResources().getDimensionPixelSize(R.dimen.abc_action_button_min_width_overflow_material);

    int cx = width;
    int cy = myView.getHeight() / 2;

    Animator anim;
    if (isShow)
        anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, 0, (float) width);
    else
        anim = ViewAnimationUtils.createCircularReveal(myView, cx, cy, (float) width, 0);

    anim.setDuration((long) 220);

    // make the view invisible when the animation is done
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!isShow) {
                super.onAnimationEnd(animation);
                myView.setVisibility(View.INVISIBLE);
            }
        }
    });

    // make the view visible and start the animation
    if (isShow)
        myView.setVisibility(View.VISIBLE);

    // start the animation
    anim.start();

}

From source file:android.view.SpringIndicator.java

/**
 * Set current point position.//from w w  w .  ja v  a2  s  . co  m
 */
private void createPoints() {
    final View view = tabs.get(viewPager.getCurrentItem());
    springView.getHeadPoint().setX(ViewCompat.getX(view) + view.getWidth() / 2);
    springView.getHeadPoint().setY(ViewCompat.getY(view) + view.getHeight() / 2);
    springView.getFootPoint().setX(ViewCompat.getX(view) + view.getWidth() / 2);
    springView.getFootPoint().setY(ViewCompat.getY(view) + view.getHeight() / 2);
    springView.animCreate();
}

From source file:com.bz.toollibrary.slidingTab.SlidingTabLayout.java

public void setCurrent(int tabIndex) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;//ww  w . j  av  a2s  .  c  o m
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild.getWidth() != 0) {
        scrollToTab(mViewPager.getCurrentItem(), 0);
    } else {
        mViewPager.postDelayed(new Runnable() {

            @Override
            public void run() {
                setCurrent(mViewPager.getCurrentItem());
            }

        }, 200);
    }
}

From source file:com.chalilayang.test.customview.springindicator.SpringIndicator.java

/**
 * Set current point position.//from  www . j  a  v a 2  s .c  om
 */
private void createPoints() {
    View view = tabs.get(viewPager.getCurrentItem());
    springView.getHeadPoint().setX(view.getX() + view.getWidth() / 2);
    springView.getHeadPoint().setY(view.getY() + view.getHeight() / 2);
    springView.getFootPoint().setX(view.getX() + view.getWidth() / 2);
    springView.getFootPoint().setY(view.getY() + view.getHeight() / 2);
    springView.animCreate();
}

From source file:android.support.v7.widget.BaseWrapContentWithAspectRatioTest.java

int getSize(View view, int orientation) {
    if (orientation == VERTICAL) {
        return view.getHeight();
    }//from w w  w  . j a va2  s . com
    return view.getWidth();
}

From source file:com.cyanogenmod.eleven.widgets.ViewPagerTabs.java

@Override
public void onPageSelected(int position) {
    position = getRtlPosition(position);
    if (mPrevSelected >= 0) {
        mTabStrip.getChildAt(mPrevSelected).setSelected(false);
    }/*from ww  w. j  a  v a  2 s  .  c  o  m*/
    final View selectedChild = mTabStrip.getChildAt(position);
    selectedChild.setSelected(true);

    // Update scroll position
    final int scrollPos = selectedChild.getLeft() - (getWidth() - selectedChild.getWidth()) / 2;
    smoothScrollTo(scrollPos, 0);
    mPrevSelected = position;
}

From source file:com.example.android.revealeffectbasic.RevealEffectBasicFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.reveal_effect_basic, container, false);

    View button = rootView.findViewById(R.id.button);

    // Set a listener to reveal the view when clicked.
    button.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w  w .  j ava  2  s.  c o  m*/
        public void onClick(View view) {
            View shape = rootView.findViewById(R.id.circle);

            // Create a reveal {@link Animator} that starts clipping the view from
            // the top left corner until the whole view is covered.
            Animator animator = ViewAnimationUtils.createCircularReveal(shape, 0, 0, 0,
                    (float) Math.hypot(shape.getWidth(), shape.getHeight()));

            // Set a natural ease-in/ease-out interpolator.
            animator.setInterpolator(new AccelerateDecelerateInterpolator());

            // Finally start the animation
            animator.start();

            Log.d(TAG, "Starting Reveal animation");
        }
    });

    return rootView;
}

From source file:app.hanks.com.conquer.activity.MainActivity.java

public void launcherAddTaskActivity(View v) {
    int[] startingLocation = new int[2];
    v.getLocationOnScreen(startingLocation);
    startingLocation[0] += v.getWidth() / 2;
    AddTaskActivity.startUserProfileFromLocation(startingLocation, this);
    overridePendingTransition(0, 0);/*from w w w  .ja  va2 s.  co m*/
}