Example usage for android.view Gravity END

List of usage examples for android.view Gravity END

Introduction

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

Prototype

int END

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

Click Source Link

Document

Push object to x-axis position at the end of its container, not changing its size.

Usage

From source file:com.justplay1.shoppist.shared.base.adapters.BaseGroupSwipeableItemAdapter.java

@Override
public void onSetChildItemSwipeBackground(CVH holder, int groupPosition, int childPosition, int type) {
    int bgResId = R.drawable.bg_swipe_item_neutral;
    LayerDrawable drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
    switch (type) {
    case SwipeableItemConstants.DRAWABLE_SWIPE_LEFT_BACKGROUND:
        switch (getLeftSwipeActionType()) {
        case SwipeActionType.MOVE_ITEM:
            if (getChildItem(groupPosition, childPosition).getStatus()) {
                bgResId = getMoveToStatusNotDoneIcon();
            } else {
                bgResId = getMoveToStatusDoneIcon();
            }/*from   w  w  w  .  ja  v  a 2  s.c om*/
            break;
        case SwipeActionType.DELETE_ITEM:
            bgResId = R.drawable.bg_swipe_item_delete_action;
            break;
        case SwipeActionType.EDIT_ITEM:
            bgResId = R.drawable.bg_swipe_item_edit_action;
            break;
        }
        drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
        ((BitmapDrawable) drawable.findDrawableByLayerId(R.id.image))
                .setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
        break;
    case SwipeableItemConstants.DRAWABLE_SWIPE_RIGHT_BACKGROUND:
        bgResId = R.drawable.bg_swipe_item_move_to_cart_action;
        switch (getRightSwipeActionType()) {
        case SwipeActionType.MOVE_ITEM:
            if (getChildItem(groupPosition, childPosition).getStatus()) {
                bgResId = getMoveToStatusNotDoneIcon();
            } else {
                bgResId = getMoveToStatusDoneIcon();
            }
            break;
        case SwipeActionType.DELETE_ITEM:
            bgResId = R.drawable.bg_swipe_item_delete_action;
            break;
        case SwipeActionType.EDIT_ITEM:
            bgResId = R.drawable.bg_swipe_item_edit_action;
            break;
        }
        drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
        ((BitmapDrawable) drawable.findDrawableByLayerId(R.id.image))
                .setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
        break;
    }
    DrawableUtils.setViewDrawable(holder.itemView, drawable);
}

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

private int distance(View sceneRoot, int viewX, int viewY, int epicenterX, int epicenterY, int left, int top,
        int right, int bottom) {
    final int side;
    if (mSide == Gravity.START) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.RIGHT : Gravity.LEFT;
    } else if (mSide == Gravity.END) {
        final boolean isRtl = ViewCompat.getLayoutDirection(sceneRoot) == ViewCompat.LAYOUT_DIRECTION_RTL;
        side = isRtl ? Gravity.LEFT : Gravity.RIGHT;
    } else {//w  w w . ja v  a2 s .  c o  m
        side = mSide;
    }
    int distance = 0;
    switch (side) {
    case Gravity.LEFT:
        distance = right - viewX + Math.abs(epicenterY - viewY);
        break;
    case Gravity.TOP:
        distance = bottom - viewY + Math.abs(epicenterX - viewX);
        break;
    case Gravity.RIGHT:
        distance = viewX - left + Math.abs(epicenterY - viewY);
        break;
    case Gravity.BOTTOM:
        distance = viewY - top + Math.abs(epicenterX - viewX);
        break;
    }
    return distance;
}

From source file:org.borderstone.tagtags.TTStartActivity.java

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

    this.setTheme(R.style.AppTheme);
    this.setContentView(R.layout.activity_start);

    Toolbar toolbar = (Toolbar) this.findViewById(R.id.toolbar);
    //toolbar.inflateMenu(R.menu.menu_start);
    toolbar.setTitle("TagTags");

    toolbar.setVisibility(View.VISIBLE);

    TTStartActivity.me = getApplicationContext();

    protocol.setAction("android.intent.action.PROTOCOL");
    settings.setAction("android.intent.action.SETTINGS");

    Constants.init(new File(this.getFilesDir(), "bsettings.txt"), this.getApplicationContext());
    Constants.fileListener = this;

    /*Load variables that are stored in a text file
      keeping version info and info about third party
      resources here, for easy editing*/
    try {//from   w ww.  j a v  a2  s. c om
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(this.getResources().openRawResource(R.raw.appinfo)));

        String line = reader.readLine();

        String[] t;
        while (line != null) {
            t = line.split(":");
            if (line.startsWith("#thirdparty:"))
                thirdparty += t[1] + "\n";
            else if (line.startsWith("#recentchanges:"))
                recentchanges += "-- " + t[1] + "\n";

            line = reader.readLine();
        }

        //just to remove the final new line.
        if (!thirdparty.equals(""))
            thirdparty = thirdparty.substring(0, thirdparty.length() - 1);
        if (!recentchanges.equals(""))
            recentchanges = recentchanges.substring(0, recentchanges.length() - 1);
    } catch (Exception ignored) {
    }

    //Most of the code below is purely for aesthetics!

    txtPhilosophy = new BTitleLabel(this);
    txtPhilosophy.setTypeface(Typeface.DEFAULT_BOLD);
    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setOnClickListener(this);
    txtPhilosophy.setTextColor(Color.BLACK);

    txtVersion = new BStandardLabel(this);
    txtVersion.setText("Recent changes:\n" + recentchanges);
    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setTextColor(Color.BLACK);

    try {
        PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
        toolbar.setSubtitle("v. " + pInfo.versionName);
    } catch (PackageManager.NameNotFoundException ignored) {
    }

    toolbar.setNavigationIcon(R.drawable.drawer);

    ImageView slu = new ImageView(this);
    ImageView sites = new ImageView(this);

    slu.setImageResource(R.drawable.slulogo);
    sites.setImageResource(R.drawable.sites);

    LinearLayout llLogos = new LinearLayout(this);
    llLogos.setOrientation(LinearLayout.HORIZONTAL);
    llLogos.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

    llLogos.addView(slu);
    llLogos.addView(sites);

    setPhiloText();

    LinearLayout back = (LinearLayout) this.findViewById(R.id.back);
    back.setOrientation(LinearLayout.VERTICAL);

    txtPhilosophy.setLayoutParams(Constants.defaultParams);
    txtPhilosophy.setBackgroundResource(R.drawable.border);

    txtVersion.setLayoutParams(Constants.defaultParams);
    txtVersion.setBackgroundResource(R.drawable.border_recurring);

    back.addView(txtPhilosophy);
    back.addView(txtVersion);
    back.addView(llLogos);

    lblSettings = new BButton(this);
    lblDownload = new BButton(this);

    lblDownload.setIcon(R.drawable.download);
    lblSettings.setIcon(R.drawable.settings);

    lblSettings.setText("Settings");
    lblDownload.setText("Download from server");

    lblSettings.setOnClickListener(this);
    lblDownload.setOnClickListener(this);

    if (!checkPermissions()) {
        final Intent intro = new Intent();
        intro.setAction("android.intent.action.INTRO");

        this.startActivity(intro);
    }

    BTitleLabel lblProperties = new BTitleLabel(this);
    BTitleLabel lblLocal = new BTitleLabel(this);
    fileNavView = new BFileNavView(this, this);

    lblProperties.setTextSize(Constants.fontSize + 2);
    lblLocal.setTextSize(Constants.fontSize + 2);

    lblProperties.setText("PROPERTIES");
    lblProperties.setTextColor(Color.WHITE);
    lblProperties.setGravity(Gravity.CENTER);
    lblLocal.setText("LOCAL FILES");
    lblLocal.setTextColor(Color.WHITE);
    lblLocal.setGravity(Gravity.CENTER);

    final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.startDrawerLayout);
    final LinearLayout drawer = (LinearLayout) this.findViewById(R.id.drawer);
    drawer.setClickable(false);
    drawer.bringToFront();

    drawer.addView(lblProperties);
    drawer.addView(lblDownload);
    drawer.addView(lblSettings);
    drawer.addView(lblLocal);
    drawer.addView(fileNavView);

    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawerLayout.isDrawerOpen(Gravity.LEFT))
                drawerLayout.openDrawer(Gravity.LEFT);
            else
                drawerLayout.closeDrawer(Gravity.LEFT);
        }
    });
}

From source file:org.videolan.vlc.gui.PlaylistActivity.java

private void fabFallback() {
    mBinding.appbar.setExpanded(false);//from  ww  w. j  a v a 2  s .c  o m
    ViewCompat.setNestedScrollingEnabled(mBinding.songs, false);
    CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) mBinding.fab.getLayoutParams();
    lp.setAnchorId(mBinding.songs.getId());
    lp.anchorGravity = Gravity.BOTTOM | Gravity.RIGHT | Gravity.END;
    lp.bottomMargin = getResources().getDimensionPixelSize(R.dimen.default_margin);
    lp.setBehavior(new FloatingActionButtonBehavior(PlaylistActivity.this, null));
    mBinding.fab.setLayoutParams(lp);
    mBinding.fab.setVisibility(View.VISIBLE);
}

From source file:net.mm2d.dmsexplorer.CdsListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        final TransitionSet ts = new TransitionSet();
        ts.addTransition(new Slide(Gravity.END));
        ts.addTransition(new Fade());
        getWindow().setEnterTransition(ts);
    }//from w  w  w  . java 2  s .  c  om
    mHandler = new Handler();
    final String udn = getIntent().getStringExtra(Const.EXTRA_UDN);
    mServer = mDataHolder.getMsControlPoint().getMediaServer(udn);
    if (mServer == null) {
        finish();
        return;
    }
    final String name = mServer.getFriendlyName();
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(ThemeUtils.getAccentDarkColor(name));
    }
    setContentView(R.layout.act_cds_list);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    toolbar.setBackgroundColor(ThemeUtils.getAccentColor(name));
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(name);

    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.progress1, R.color.progress2, R.color.progress3,
            R.color.progress4);
    mSwipeRefreshLayout.setOnRefreshListener(() -> {
        mDataHolder.popCache();
        reload();
    });
    mCdsListAdapter = new CdsListAdapter(this);
    mCdsListAdapter.setOnItemClickListener(this::onCdsItemClick);
    mRecyclerView = (RecyclerView) findViewById(R.id.cds_list);
    mRecyclerView.setAdapter(mCdsListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this));

    if (findViewById(R.id.cds_detail_container) != null) {
        mTwoPane = true;
    }
    if (savedInstanceState == null) {
        browse(0, "0", "", true);
    }
}

From source file:com.cnlms.wear.NotificationHelper.java

public static void raiseNotificationWithWearableExtensions(final Context context) {

    //  Wearable Extensions
    final NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender();

    wearableExtender.addAction(mapAction(context));
    wearableExtender.setHintHideIcon(true);
    wearableExtender.setBackground(BitmapFactory.decodeResource(context.getResources(), R.drawable.wear));

    wearableExtender.setContentIcon(R.drawable.gplus);
    wearableExtender.setContentIconGravity(Gravity.END);

    final NotificationCompat.Builder builder = defaultBuilder(context);

    builder.setContentIntent(viewPendingIntent(context)).addAction(replyAction(context))
            .extend(wearableExtender);//from  www  .ja  va2  s  . com

    //  Big Style
    /*NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle();
    style.bigText(CONTENT_BIG_TEXT);
            
    builder.setStyle(style);*/

    raiseNotification(context, builder);

}

From source file:io.github.yavski.fabspeeddial.FabSpeedDial.java

private void init(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FabSpeedDial, 0, 0);
    resolveCompulsoryAttributes(typedArray);
    resolveOptionalAttributes(typedArray);
    typedArray.recycle();//from ww w . j a va2 s.  com

    if (isGravityBottom()) {
        LayoutInflater.from(context).inflate(R.layout.fab_speed_dial_bottom, this, true);
    } else {
        LayoutInflater.from(context).inflate(R.layout.fab_speed_dial_top, this, true);
    }

    if (isGravityEnd()) {
        setGravity(Gravity.END);
    }

    menuItemsLayout = (LinearLayout) findViewById(R.id.menu_items_layout);

    setOrientation(VERTICAL);

    newNavigationMenu();

    int menuItemCount = navigationMenu.size();
    fabMenuItemMap = new HashMap<>(menuItemCount);
    cardViewMenuItemMap = new HashMap<>(menuItemCount);
}

From source file:org.odk.collect.android.activities.AppListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SORT:
        if (drawerLayout.isDrawerOpen(Gravity.END)) {
            drawerLayout.closeDrawer(Gravity.END);
        } else {//from w  w w.  j av  a 2s.c  o m
            Collect.getInstance().hideKeyboard(inputSearch);
            drawerLayout.openDrawer(Gravity.END);
        }
        return true;

    case MENU_FILTER:
        if (searchBoxLayout.getVisibility() == View.GONE) {
            showSearchBox();
        } else {
            hideSearchBox();
        }
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:sg.fxl.topeka.widget.quiz.AbsQuizView.java

private void addFloatingActionButton() {
    final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab);
    int bottomOfQuestionView = findViewById(R.id.question_view).getBottom();
    final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP);
    final int halfAFab = fabSize / 2;
    fabLayoutParams.setMargins(0, // left
            bottomOfQuestionView - halfAFab, //top
            0, // right
            spacingDouble); // bottom
    MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, spacingDouble);
    if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Account for the fab's emulated shadow.
        fabLayoutParams.topMargin -= (submitAnswer.getPaddingTop() / 2);
    }//from www .j  a v a 2  s . c  om
    addView(submitAnswer, fabLayoutParams);
}

From source file:com.google.samples.apps.topeka.widget.quiz.AbsQuizView.java

private void addFloatingActionButton() {
    final int fabSize = getResources().getDimensionPixelSize(R.dimen.size_fab);
    int bottomOfQuestionView = findViewById(R.id.question_view).getBottom();
    final LayoutParams fabLayoutParams = new LayoutParams(fabSize, fabSize, Gravity.END | Gravity.TOP);
    final int halfAFab = fabSize / 2;
    fabLayoutParams.setMargins(0, // left
            bottomOfQuestionView - halfAFab, //top
            0, // right
            mSpacingDouble); // bottom
    MarginLayoutParamsCompat.setMarginEnd(fabLayoutParams, mSpacingDouble);
    if (ApiLevelHelper.isLowerThan(Build.VERSION_CODES.LOLLIPOP)) {
        // Account for the fab's emulated shadow.
        fabLayoutParams.topMargin -= (mSubmitAnswer.getPaddingTop() / 2);
    }/* ww  w  . j  a v  a 2 s  . c  o m*/
    addView(mSubmitAnswer, fabLayoutParams);
}