Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

In this page you can find the example usage for android.view Gravity BOTTOM.

Prototype

int BOTTOM

To view the source code for android.view Gravity BOTTOM.

Click Source Link

Document

Push object to the bottom of its container, not changing its size.

Usage

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//from   w  ww  . j a v a2  s  . c om
    LinearLayout container = new LinearLayout(context);
    container.setLayoutParams(CommonLayouts.FULL_WIDTH);
    container.setOrientation(LinearLayout.HORIZONTAL);
    container.setGravity(Gravity.CENTER);

    ImageView imageView = new ImageView(context);
    imageView.setImageResource(R.drawable.play);
    imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));

    TextView valueTV = new TextView(context);
    valueTV.setText(asText(content));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT);
    valueTV.setPadding(4, 0, 0, 0);

    container.addView(imageView);
    container.addView(valueTV);
    frame.addView(container);
}

From source file:com.brookmanholmes.bma.wizard.ui.StepPagerStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (pageCount == 0) {
        return;/*from  ww w.j  av a2s  . c o m*/
    }

    float totalWidth = pageCount * (tabWidth + indicatorSpacing) - indicatorSpacing;
    float totalcx;
    float cy;
    boolean fillHorizontal = false;

    switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        totalcx = (getWidth() - totalWidth) / 2;
        break;
    case Gravity.RIGHT:
        totalcx = getWidth() - getPaddingRight() - totalWidth;
        break;
    case Gravity.FILL_HORIZONTAL:
        totalcx = getPaddingLeft();
        fillHorizontal = true;
        break;
    default:
        totalcx = getPaddingLeft();
    }

    switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.CENTER_VERTICAL:
        cy = (int) (getHeight() - tabHeight) / 2;
        break;
    case Gravity.BOTTOM:
        cy = getHeight() - getPaddingBottom() - tabHeight;
        break;
    default:
        cy = getPaddingTop();
    }

    float center = cy + tabHeight / 2;

    float tabWidth = this.tabWidth;
    if (fillHorizontal) {
        tabWidth = (getWidth() - getPaddingRight() - getPaddingLeft() - (pageCount - 1) * indicatorSpacing)
                / pageCount;
    }

    for (int i = 0; i < pageCount; i++) {
        float cx = totalcx + (i * (tabWidth + indicatorSpacing));

        Paint tempPaint;

        if (i < currentPage)
            tempPaint = prevTabPaint;
        else if (i > currentPage)
            tempPaint = nextTabPaint;
        else
            tempPaint = selectedTabPaint;

        canvas.drawCircle(cx, center, i == currentPage ? radius : nonCurrentRadius, tempPaint);
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.tablet.MapMultiPaneActivity.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE);

    LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer);
    spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL);
    spacerView.setGravity(landscape ? Gravity.END : Gravity.BOTTOM);

    View popupView = findViewById(R.id.map_detail_popup);
    LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams();
    popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT;
    popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0;
    popupView.setLayoutParams(popupLayoutParams);

    popupView.requestLayout();/* ww w.j  a  v  a2 s .  c om*/

    updateMapPadding();
}

From source file:com.example.android.navigationdrawerexample.BottomDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_bottom_drawer);

    mTitle = mDrawerTitle = getTitle();//from  w  ww .ja va  2s  .  c o m
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mVerticalDrawerLayout = (VerticalDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.bottom_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mVerticalDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mVerticalDrawerToggle = new ActionBarVerticalDrawerToggle(this, /* host Activity */
            getSupportActionBar(), /* ActionBar of the hosting Activity */
            mVerticalDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mVerticalDrawerToggle.setGravity(Gravity.BOTTOM);
    mVerticalDrawerLayout.setDrawerListener(mVerticalDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
}

From source file:br.ufrn.dimap.pubshare.download.service.DownloaderService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Toast toast = Toast.makeText(this, "Starting download. see action bar to see the progress.",
            Toast.LENGTH_SHORT);/*from ww  w . j a  v  a2 s  .  c  o  m*/
    toast.setGravity(Gravity.BOTTOM | Gravity.CENTER, 0, 0);
    toast.show();
    return super.onStartCommand(intent, flags, startId);
}

From source file:com.culinars.culinars.WrapContentViewPager.java

/**
 * Allows to redraw the view size to wrap the content of the bigger child.
 *
 * @param widthMeasureSpec  with measured
 * @param heightMeasureSpec height measured
 *//*from  w ww  . ja  v  a  2 s.  c om*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    widthMeasuredSpec = widthMeasureSpec;
    int mode = MeasureSpec.getMode(heightMeasureSpec);

    if (mode == MeasureSpec.UNSPECIFIED || mode == MeasureSpec.AT_MOST) {
        if (height == 0) {
            // measure vertical decor (i.e. PagerTitleStrip) based on ViewPager implementation
            decorHeight = 0;
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                LayoutParams lp = (LayoutParams) child.getLayoutParams();
                if (lp != null && lp.isDecor) {
                    int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
                    boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM;
                    if (consumeVertical) {
                        decorHeight += child.getMeasuredHeight();
                    }
                }
            }

            // make sure that we have an height (not sure if this is necessary because it seems that onPageScrolled is called right after
            int position = getCurrentItem();
            View child = getViewAtPosition(position);
            if (child != null) {
                height = measureViewHeight(child);
            }
            Log.d(TAG, "onMeasure height:" + height + " decor:" + decorHeight);

        }
        int totalHeight = height + decorHeight + getPaddingBottom() + getPaddingTop();
        heightMeasureSpec = MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY);
        Log.d(TAG, "onMeasure total height:" + totalHeight);
    }

    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

From source file:com.jlt.unsplashd.DetailActivity.java

@Override
// begin onCreate
protected void onCreate(Bundle savedInstanceState) {

    // 0. super things
    // 1. use the detail layout
    // 2. bind things
    // 3. show the image
    // 3a. using the uri from the intent
    // 3b. using the place holder color
    // 3c. into the correct view
    // 4. set author text from intent
    // 5. when the back toolbar button is tapped
    // 5a. close activity after transition is done
    // 6. for lollipop devices
    // 6a. slide description from bottom

    // 0. super things

    super.onCreate(savedInstanceState);

    // 1. use the detail layout

    setContentView(R.layout.activity_detail);

    // 2. bind things

    ButterKnife.bind(this);

    // 3. show the image

    Picasso.with(this)

            // 3a. using the uri from the intent

            .load(getIntent().getData())

            // 3b. using the place holder color

            .placeholder(R.color.colorPlaceholder)

            // 3c. into the correct view

            .into(threeTwoImageView);/*from   ww  w  . ja  v  a  2 s .  com*/

    // 4. set author text from intent

    authorTextView.setText(getString(R.string.author_name, getIntent().getStringArrayExtra(EXTRA_AUTHOR_NAME)));

    // 5. when the back toolbar button is tapped

    // begin toolbar.setNavigationOnClickListener
    toolbar.setNavigationOnClickListener(

            // begin new View.OnClickListener
            new View.OnClickListener() {

                @Override
                // begin onClick
                public void onClick(View view) {

                    // 5a. close activity after transition is done

                    finishAfterTransition();

                } // end onClick

            } // end new View.OnClickListener

    ); // end toolbar.setNavigationOnClickListener

    // 6. for lollipop devices

    // begin if lollipop and above
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        // 6a. slide description from bottom

        Slide slide = new Slide(Gravity.BOTTOM);

        slide.addTarget(R.id.ad_ll_description);

        slide.setInterpolator(new FastOutSlowInInterpolator());

        slide.setDuration(slideDuration);

        getWindow().setEnterTransition(slide);

    } // end if lollipop and above

}

From source file:cn.djangoogle.pull2load.internal.LoadingLayout.java

public LoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) {
    super(context);
    mMode = mode;//from  w ww . j a  v a  2  s .c o m
    mScrollDirection = scrollDirection;

    switch (scrollDirection) {
    case HORIZONTAL:
        LayoutInflater.from(context).inflate(R.layout.pull2load_header_horizontal, this);
        break;
    case VERTICAL:
    default:
        LayoutInflater.from(context).inflate(R.layout.pull2load_header_vertical, this);
        break;
    }

    mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner);
    mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text);
    mHeaderProgressWheel = (ProgressWheel) mInnerLayout.findViewById(R.id.pull_to_refresh_progress_wheel);
    mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text);
    mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image);

    LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams();

    switch (mode) {
    case PULL_FROM_END:
        lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label);
        break;

    case PULL_FROM_START:
    default:
        lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT;

        // Load in labels
        mPullLabel = context.getString(R.string.pull_to_refresh_pull_label);
        mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label);
        mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label);
        break;
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) {
        Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground);
        if (null != background) {
            ViewCompat.setBackground(this, background);
        }
    }

    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID);
        setTextAppearance(styleID.data);
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance)) {
        TypedValue styleID = new TypedValue();
        attrs.getValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID);
        setSubTextAppearance(styleID.data);
    }

    // Text Color attrs need to be set after TextAppearance attrs
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor);
        if (null != colors) {
            setTextColor(colors);
        }
    }
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) {
        ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor);
        if (null != colors) {
            setSubTextColor(colors);
        }
    }

    // Try and get defined drawable from Attrs
    Drawable imageDrawable = null;
    if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawable)) {
        imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawable);
    }

    // Check Specific Drawable from Attrs, these overrite the generic
    // drawable attr above
    switch (mode) {
    case PULL_FROM_START:
    default:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableStart)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableStart);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableTop)) {
            Pull2LoadCommonUtil.warnDeprecation("ptrDrawableTop", "ptrDrawableStart");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableTop);
        }
        break;

    case PULL_FROM_END:
        if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableEnd)) {
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableEnd);
        } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableBottom)) {
            Pull2LoadCommonUtil.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd");
            imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableBottom);
        }
        break;
    }

    // If we don't have a user defined drawable, load the default
    if (null == imageDrawable) {
        imageDrawable = ContextCompat.getDrawable(context, getDefaultDrawableResId());
    }

    // Set Drawable, and save width/height
    setLoadingDrawable(imageDrawable);

    reset();
}

From source file:com.recyclerviewpulldownrefresh.view.refresh.AbPullToRefreshView.java

/**
 * add HeaderView./*w ww  .j a  v a 2  s  . co m*/
 */
private void addHeaderView() {
    mHeaderView = new AbListViewHeader(mContext);
    mHeaderViewHeight = mHeaderView.getHeaderHeight();
    mHeaderView.setGravity(Gravity.BOTTOM);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mHeaderViewHeight);
    // topMarginheader View,???
    params.topMargin = -mHeaderViewHeight;
    addView(mHeaderView, params);
}

From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (sheet != null) {
        throw new UnsupportedOperationException("BottomSheet must only have 1 child view");
    }//  w w w  . j a v  a 2 s .c o m
    sheet = child;
    sheetOffsetHelper = new ViewOffsetHelper(sheet);
    sheet.addOnLayoutChangeListener(sheetLayout);
    // force the sheet contents to be gravity bottom. This ain't a top sheet.
    ((LayoutParams) params).gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
    super.addView(child, index, params);
}