Example usage for android.widget RelativeLayout getWidth

List of usage examples for android.widget RelativeLayout getWidth

Introduction

In this page you can find the example usage for android.widget RelativeLayout getWidth.

Prototype

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

Source Link

Document

Return the width of your view.

Usage

From source file:Main.java

public static void startAnimIn(RelativeLayout view) {
    RotateAnimation ra = new RotateAnimation(180, 360, view.getWidth() / 2, view.getHeight());
    ra.setDuration(500);//w w  w  .j a v  a 2 s.  c  om
    ra.setFillAfter(true);
    view.startAnimation(ra);
}

From source file:Main.java

public static void viewShow(RelativeLayout view) {

    RotateAnimation animation = new RotateAnimation(180, 360, view.getWidth() / 2, view.getHeight());
    animation.setDuration(300);/*from  w w w.  j a  v a  2  s  .c  o  m*/
    animation.setFillAfter(true);
    view.startAnimation(animation);

}

From source file:Main.java

public static void rotateOutAnimation(RelativeLayout level, long i) {
    RotateAnimation animation = new RotateAnimation(0, 180, level.getWidth() / 2, level.getHeight());
    animation.setFillAfter(true);//w w  w  .  j av a  2s  .  co  m
    animation.setDuration(500);
    animation.setStartOffset(i);
    level.startAnimation(animation);
}

From source file:Main.java

public static void rotateInAnimation(RelativeLayout level, long i) {
    RotateAnimation animation = new RotateAnimation(180, 360, level.getWidth() / 2, level.getHeight());
    animation.setFillAfter(true);/*from www  . j av a  2  s .co  m*/
    animation.setDuration(500);
    animation.setStartOffset(i);
    level.startAnimation(animation);
}

From source file:Main.java

public static boolean isPointInsideOption(Point balloonLocation, RelativeLayout optionLayout) {
    int[] optionLocation = new int[2];

    optionLayout.getLocationInWindow(optionLocation);

    int x = balloonLocation.x;
    int y = balloonLocation.y;

    int oX = optionLocation[0];
    int oY = optionLocation[1];

    if (y >= oY && y <= oY + optionLayout.getHeight() && x >= oX && x <= oX + optionLayout.getWidth()) {

        return true;

    } else//  w w  w. java2  s  . c  o m
        return false;
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Fill the moneybox with all the movements dropping coins randomly
 *///  w  w w .j a v a 2 s .  c  o  m
public void fillMoneybox() {
    RelativeLayout layout;
    int maxWidth;
    ArrayList<Movement> lstMoney;
    Random rndLeft;
    double total;
    int i;
    MainActivity parent;

    parent = (MainActivity) getActivity();

    layout = findLayout();
    maxWidth = layout.getWidth();
    if (maxWidth == 0) {
        // The layout is not initialized
        return;
    }

    total = 0.0;
    i = 0;

    rndLeft = new Random();
    lstMoney = MovementsManager.getActiveMovements(parent.getCurrentMoneybox());
    for (Movement m : lstMoney) {
        Rect r;
        CurrencyValueDef curr;
        int left;

        curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount()));
        if (curr != null) {
            r = curr.getDrawable().getBounds();

            left = rndLeft.nextInt(maxWidth - r.width());

            total += m.getAmount();

            MoneyTimerTask task;

            task = new MoneyTimerTask(this, m, left, r.width(), total);

            layout.postDelayed(task, 400 * i);
        }

        i++;
    }
}

From source file:de.tobiasbielefeld.solitaire.games.Game.java

/**
 * Returns the calculated horizontal spacing for the layout. It takes the layout width minus the card widths,
 * then divides the remaining space with the divider. So the game can know how big the spaces are
 * between the card stacks for a good layout.
 *
 * @param layoutGame    The layout where the cards are located in.
 * @param numberOfCards The number of cards in a row
 * @param divider       The amount of spaces you want to have between the cards
 * @return The spacing value/*w w w . j  av  a2  s  . c o m*/
 */
protected int setUpHorizontalSpacing(RelativeLayout layoutGame, int numberOfCards, int divider) {
    return min(Card.width / 2, (layoutGame.getWidth() - numberOfCards * Card.width) / (divider));
}

From source file:de.tobiasbielefeld.solitaire.games.Game.java

/**
 * mirrors the textViews, if there are any. Used for left handed mode
 *///w w  w.  j  av  a  2  s  . c o m
public void mirrorTextViews(RelativeLayout layoutGame) {
    for (TextView textView : textViews) {
        textView.setX(layoutGame.getWidth() - textView.getX() - Card.width);
    }
}

From source file:com.cachirulop.moneybox.fragment.MoneyboxFragment.java

/**
 * Drop money from the top of the layout to the bottom simulating that a
 * coin or bill is inserted in the moneybox.
 * /*from w  ww . j  a  v  a2 s .  c  o  m*/
 * @param leftMargin
 *            Left side of the coin/bill
 * @param width
 *            Width of the image to slide down
 * @param m
 *            Movement with the value of the money to drop
 */
protected void dropMoney(int leftMargin, int width, Movement m) {
    ImageView money;
    AnimationSet moneyDrop;
    RelativeLayout layout;
    RelativeLayout.LayoutParams lpParams;
    Rect r;
    Activity parent;
    CurrencyValueDef curr;

    parent = getActivity();

    curr = CurrencyManager.getCurrencyDef(Math.abs(m.getAmount()));
    r = curr.getDrawable().getBounds();

    money = new ImageView(parent);
    money.setVisibility(View.INVISIBLE);
    money.setImageDrawable(curr.getDrawable().getConstantState().newDrawable());
    money.setTag(curr);
    money.setId((int) m.getIdMovement());

    layout = findLayout();

    lpParams = new RelativeLayout.LayoutParams(r.width(), r.height());
    lpParams.leftMargin = leftMargin;
    lpParams.rightMargin = layout.getWidth() - (leftMargin + width);
    lpParams.topMargin = 0;
    lpParams.bottomMargin = r.height();

    layout.addView(money, lpParams);

    moneyDrop = createDropAnimation(money, layout, curr);
    money.setVisibility(View.VISIBLE);

    SoundsManager.playMoneySound(curr.getType());
    VibratorManager.vibrateMoneyDrop(curr.getType());

    money.startAnimation(moneyDrop);
}

From source file:de.tobiasbielefeld.solitaire.games.Game.java

/**
 * Use this to set the cards width according to the last two values.
 * second last is for portrait mode, last one for landscape.
 * the game width will be divided by these values according to orientation to use as card widths.
 * Card height is 1.5*width and the dimensions are applied to every card and stack
 *
 * @param layoutGame     The layout, where the cards are located in
 * @param isLandscape    Shows if the phone is currently in landscape mode
 * @param portraitValue  The limiting number of card in the biggest row of the layout
 * @param landscapeValue The limiting number of cards in the biggest column of the layout
 *///  ww  w .ja v a  2  s.  c  om
protected void setUpCardWidth(RelativeLayout layoutGame, boolean isLandscape, int portraitValue,
        int landscapeValue) {
    Card.width = isLandscape ? layoutGame.getWidth() / (landscapeValue)
            : layoutGame.getWidth() / (portraitValue);
    Card.height = (int) (Card.width * 1.5);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(Card.width, Card.height);
    for (Card card : cards)
        card.view.setLayoutParams(params);
    for (Stack stack : stacks)
        stack.view.setLayoutParams(params);
}