List of usage examples for android.widget RelativeLayout getHeight
@ViewDebug.ExportedProperty(category = "layout") public final int getHeight()
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 ww . j av a 2 s . co m*/ 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);/*www . j av a 2 s . c om*/ 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);/* www .j a v a2s . c om*/ 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 w w w .j a va 2s.c o 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//from w w w . j a v a 2 s . c o m return false; }
From source file:com.arcusapp.soundbox.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //start the MediaPlayerService Intent serviceIntent = new Intent(SoundBoxApplication.ACTION_MEDIA_PLAYER_SERVICE, null, SoundBoxApplication.getContext(), MediaPlayerService.class); startService(serviceIntent);// w w w . j a va 2 s .com mPlayFragment = (PlayFragment) getSupportFragmentManager().findFragmentById(R.id.playFragmentContainer); //set up the sliding layout mSlidingLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); // set the height of the sliding panel final RelativeLayout slidingPanel = (RelativeLayout) findViewById(R.id.slidingPanel); slidingPanel.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // gets called after layout has been done but before display int height = slidingPanel.getHeight(); mSlidingLayout.setPanelHeight(height); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { slidingPanel.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { slidingPanel.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); mSlidingLayout.setPlayFragment(mPlayFragment); TextView dragerView = (TextView) findViewById(R.id.txtSongTitle); mSlidingLayout.setDragView(dragerView); mSlidingLayout.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { } @Override public void onPanelCollapsed(View panel) { //enable ViewPager Fragments mViewPager.setContentEnabled(true); //inform the fragment that panel is collapsed mPlayFragment.setPanelExpanded(false); mPanelExpanded = false; } @Override public void onPanelExpanded(View panel) { //disable ViewPager Fragments mViewPager.setContentEnabled(false); //inform the fragment that panel is expanded mPlayFragment.setPanelExpanded(true); mPanelExpanded = true; } @Override public void onPanelAnchored(View panel) { } }); // Set up the action bar. final android.support.v7.app.ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setContentEnabled(true); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.mycompany.popularmovies.DetailActivity.DetailFragment.java
@Override public void onClick(View v) { if (v.getId() == R.id.favorite) { Uri uri = MovieContract.MovieTable.CONTENT_URI; ContentResolver resolver = mActivity.getContentResolver(); Cursor favoriteStatusCursor = resolver.query(uri, new String[] { MovieContract.MovieTable.COLUMN_FAVORITED }, MovieContract.MovieTable._ID + "== ?", new String[] { Integer.toString(mMovieId) }, null); if (favoriteStatusCursor != null && favoriteStatusCursor.moveToFirst()) { Integer favoriteStatus = favoriteStatusCursor .getInt(favoriteStatusCursor.getColumnIndex(MovieContract.MovieTable.COLUMN_FAVORITED)); Integer flippedFavoriteStatus = favoriteStatus == 0 ? 1 : 0; ContentValues updateFavoriteStatusValues = new ContentValues(); updateFavoriteStatusValues.put(MovieContract.MovieTable.COLUMN_FAVORITED, flippedFavoriteStatus); resolver.update(uri, updateFavoriteStatusValues, MovieContract.MovieTable._ID + " == ?", new String[] { Integer.toString(mMovieId) }); favoriteStatusCursor.close(); }/* w ww . j a v a2 s. c om*/ } else if (v.getId() == R.id.trailer_thumbnail) { String link = (String) v.getTag(); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(link))); } else if (v.getId() == R.id.review) { final RelativeLayout reviewItem = (RelativeLayout) v; final TextView author = (TextView) v.findViewById(R.id.author_full_name); final TextView review = (TextView) v.findViewById(R.id.review_text); if (reviewItem.getTag() == DetailFragment.TAG_REVIEW_COLLAPSED) { author.setVisibility(View.VISIBLE); review.setMaxLines(Integer.MAX_VALUE); new Handler().post(new Runnable() { @Override public void run() { int excess = mReviewList.getTop() + reviewItem.getBottom() - (mScrollView.getScrollY() + mScrollView.getHeight()); if (excess > 0) { if (reviewItem.getHeight() <= mScrollView.getHeight()) { mScrollView.smoothScrollBy(0, excess); } else { mScrollView.smoothScrollTo(0, mReviewList.getTop() + reviewItem.getTop()); } } } }); reviewItem.setTag(DetailFragment.TAG_REVIEW_EXPANDED); } else { author.setVisibility(View.GONE); review.setMaxLines(REVIEW_MAXLINES); reviewItem.setTag(DetailFragment.TAG_REVIEW_COLLAPSED); } } }
From source file:com.sociablue.nanodegree_p1.MovieListFragment.java
private void initializeFab(View rootView) { final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container); final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab); final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar); final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar); Fab.setOnClickListener(new View.OnClickListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from ww w .j a v a 2s . co m*/ public void onClick(View v) { //Menu Button Icon Animation //Setting up necessary variables long animationDuration = 500; float containerHeight = buttonContainer.getHeight(); float containerCenterY = containerHeight / 2; float containerCenterX = buttonContainer.getWidth() / 2; float topBarCenter = topBar.getTop() + topBar.getHeight() / 2; float widthOfBar = topBar.getWidth(); float heightOfBar = topBar.getHeight(); final float distanceBetweenBars = (containerCenterY - topBarCenter); /** *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties *and objects at the same time. Also, will try to break intialization into smaller functions. */ //Setting up animations of hamburger bars and rotation /** * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar. * Y Translation is 1/2 the height of the hamburger bar minus the distance. * Subtracting the distance from the height because the distance between bars is * calculated of the exact center of the button. * With out the subtraction the bar would translate slightly below the middle bar. */ float yTranslation = heightOfBar / 2 - distanceBetweenBars; float xTranslation = widthOfBar / 2 + heightOfBar / 2; TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars); topBarTranslationAnim.setDuration((long) (animationDuration * 0.8)); topBarTranslationAnim.setFillAfter(true); //Animation for bottom hamburger bar. Translates and Rotates to create 'X' AnimationSet bottomBarAnimation = new AnimationSet(true); bottomBarAnimation.setFillAfter(true); //Rotate to create cross. (The cross becomes the X after the button rotation completes" RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f); bottomBarRotationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarRotationAnimation); //Translate to correct X alignment TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, -yTranslation); bottomBarTranslationAnimation.setDuration(animationDuration); bottomBarAnimation.addAnimation(bottomBarTranslationAnimation); //Button Specific Animations //Rotate Button Container RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); containerRotationAnimation.setDuration(animationDuration); containerRotationAnimation.setFillAfter(true); //Animate change of button color between Active and Disabled colors that have been //defined in color.xml int activeColor = getResources().getColor(R.color.active_button); int disabledColor = getResources().getColor(R.color.disabled_button); //Need to use ValueAnimator because property animator does not support BackgroundTint ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor); buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue())); } }); buttonColorAnimation.setDuration(animationDuration); //Start all the animations topBar.startAnimation(topBarTranslationAnim); bottomBar.startAnimation(bottomBarAnimation); buttonContainer.startAnimation(containerRotationAnimation); buttonColorAnimation.start(); //Toogle mMenu open and closed if (mMenu.isOpen()) { //If mMenu is open, do the reverse of the animation containerRotationAnimation .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator())); buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator())); mMenu.close(); } else { bottomBarAnimation.setInterpolator(new AccelerateInterpolator()); mMenu.open(); } } }); }
From source file:de.tobiasbielefeld.solitaire.games.Game.java
/** * Returns the calculated vertical 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//from w ww . j av a 2 s . c o m */ protected int setUpVerticalSpacing(RelativeLayout layoutGame, int numberOfCards, int divider) { return min(Card.width / 2, (layoutGame.getHeight() - numberOfCards * Card.height) / (divider)); }
From source file:de.tobiasbielefeld.solitaire.games.Game.java
/** * use this to automatically set up the dimensions (then the call of setUpCardWidth() isn't necessary). * It will take the layout, a value for width and a value for height. The values * represent the limiting values for the orientation. For example : There are 7 rows, so 7 * stacks have to fit on the horizontal axis, but also 4 cards in the height. The method uses * these values to calculate the right dimensions for the cards, so everything fits fine on the screen * * @param layoutGame The layout, where the cards are located in * @param cardsInRow The limiting number of card in the biggest row of the layout * @param cardsInColumn The limiting number of cards in the biggest column of the layout *//* ww w .j ava2s . c o m*/ protected void setUpCardDimensions(RelativeLayout layoutGame, int cardsInRow, int cardsInColumn) { int testWidth1, testHeight1, testWidth2, testHeight2; testWidth1 = layoutGame.getWidth() / cardsInRow; testHeight1 = (int) (testWidth1 * 1.5); testHeight2 = layoutGame.getHeight() / cardsInColumn; testWidth2 = (int) (testHeight2 / 1.5); if (testHeight1 < testHeight2) { Card.width = testWidth1; Card.height = testHeight1; } else { Card.width = testWidth2; Card.height = testHeight2; } 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); }