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.github.xizzhu.simpletooltip.sample.MainActivity.java

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

    setContentView(R.layout.activity_main);
    findViewById(R.id.top_left_button).setOnClickListener(new View.OnClickListener() {
        @Override//w w w.  ja v a2s .c om
        public void onClick(View v) {
            showToolTipView(v, Gravity.RIGHT, "Simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.blue));
        }
    });
    findViewById(R.id.top_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.BOTTOM, "It is yet another very simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.green));
        }
    });
    findViewById(R.id.central_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.END, "It is a very simple tool tip in the center!",
                    ContextCompat.getColor(MainActivity.this, R.color.magenta));
        }
    });
    findViewById(R.id.bottom_left_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.TOP, "Tool tip, once more!",
                    ContextCompat.getColor(MainActivity.this, R.color.maroon));
        }
    });
    findViewById(R.id.bottom_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.LEFT, "Magical tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.navy));
        }
    });

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipViewWithParent((Button) v, Gravity.BOTTOM);
        }
    };
    findViewById(R.id.button1).setOnClickListener(listener);
    findViewById(R.id.button2).setOnClickListener(listener);
    findViewById(R.id.button3).setOnClickListener(listener);
    findViewById(R.id.button4).setOnClickListener(listener);
    findViewById(R.id.button5).setOnClickListener(listener);
    findViewById(R.id.button6).setOnClickListener(listener);
    findViewById(R.id.button7).setOnClickListener(listener);

    showToolTipView(findViewById(R.id.central_button), Gravity.START, "A simple tool tip!",
            ContextCompat.getColor(MainActivity.this, R.color.magenta), 750L);
}

From source file:com.facebook.react.views.drawer.ReactDrawerLayoutManager.java

@ReactProp(name = "drawerPosition", defaultInt = Gravity.START)
public void setDrawerPosition(ReactDrawerLayout view, int drawerPosition) {
    if (Gravity.START == drawerPosition || Gravity.END == drawerPosition) {
        view.setDrawerPosition(drawerPosition);
    } else {/*from ww  w.  j a  v a  2s. c  o  m*/
        throw new JSApplicationIllegalArgumentException("Unknown drawerPosition " + drawerPosition);
    }
}

From source file:com.kaliturin.blacklist.adapters.SMSConversationCursorAdapter.java

public SMSConversationCursorAdapter(Context context) {
    super(context, null, 0);
    paddingStart = new Padding(context, Gravity.START, 5, 50);
    paddingEnd = new Padding(context, Gravity.END, 5, 50);

    calendar.setTimeInMillis(System.currentTimeMillis());
    currentYear = calendar.get(Calendar.YEAR);
    currentDay = calendar.get(Calendar.DAY_OF_YEAR);
}

From source file:com.josecalles.porridge.home.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    ButterKnife.bind(this);
    injectPresenter();/*from   w  w w .  j  a  va 2 s  .co  m*/
    setActionBar(mToolbar);
    setupDrawerLayout();
    setupNavigationView();
    getWindow().setEnterTransition(new Slide(Gravity.END));
    checkIfCameFromEvents();
}

From source file:org.onebusaway.android.report.ui.BaseReportActivity.java

protected void setUpProgressBar() {
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.END;

    ProgressBar progressBar = new ProgressBar(this);
    progressBar.setIndeterminate(true);/*from  w w  w . j av a 2  s  .co  m*/
    progressBar.setVisibility(View.GONE);
    progressBar.setIndeterminate(true);
    progressBar.setLayoutParams(params);
    progressBar.getIndeterminateDrawable().setColorFilter(Color.WHITE,
            android.graphics.PorterDuff.Mode.MULTIPLY);

    ActionBar ab = getSupportActionBar();
    if (ab != null) {
        ab.setDisplayShowCustomEnabled(true);
        ab.setCustomView(progressBar);
    }
}

From source file:com.inha.stickyonpage.MainActivity.java

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

    registerReceiver(mBroadcastReceiver, new IntentFilter("FINISH"));

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    //        mDrawerLayout.openDrawer(Gravity.END);
    mDrawerLayout.closeDrawer(Gravity.END);

    mFrameLayout = (FrameLayout) findViewById(R.id.drawer_main);
    mMemoLinearLayout = (MemoLinearLayout) findViewById(R.id.drawer_left);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    if (!Const.external_URL) {
        Const.URL = Const.HOME_URL;
        RecentStickyView stickyFragment = new RecentStickyView();
        ft.add(R.id.drawer_main, stickyFragment, "RecentStickyView");
    } else {/*from w  w  w  .  java  2  s . co  m*/
        BrowsingWebView browsingFragment = new BrowsingWebView();
        ft.add(R.id.drawer_main, browsingFragment, "BrowsingWebView");
        Const.external_URL = false; // reset flag
    }
    ft.commit();
}

From source file:com.ouyangzn.github.module.main.MainActivity.java

@Override
protected void initView(Bundle savedInstanceState) {
    Toolbar toolbar = ButterKnife.findById(this, R.id.toolbar);
    UiUtils.setCenterTitle(toolbar, R.string.app_name);
    ImageView collectImg = UiUtils.addImage2Toolbar(toolbar, R.drawable.selector_collect, Gravity.END,
            new int[] { 0, 0, ScreenUtils.dp2px(mContext, 15), 0 });
    collectImg.setId(R.id.id_toolbar_right_img);
    collectImg.setOnClickListener(this);
    // @BindView ?NavigationViewviewfind?
    mNavView = ButterKnife.findById(this, R.id.nav_view);
    mNavView.setNavigationItemSelectedListener(this);
    View headerView = mNavView.getHeaderView(0);
    mImgAvatar = (ImageView) headerView.findViewById(R.id.img_photo);
    mTvEmail = (TextView) headerView.findViewById(R.id.tv_email);
    User user = App.getUser();/*from   w w  w.j a v  a 2  s .com*/
    if (user != null) {
        ImageLoader.loadAsCircle(mImgAvatar, R.drawable.ic_default_photo, user.getAvatarUrl());
        mTvEmail.setText(user.getEmail());
    } else {
        mImgAvatar.setImageResource(R.drawable.ic_default_photo);
        mTvEmail.setText(null);
    }

    // @BindView ?
    mDrawerLayout = ButterKnife.findById(this, R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    toggle.syncState();

    ViewPager viewPager = ButterKnife.findById(this, R.id.view_pager_main);
    TabLayout tabLayout = ButterKnife.findById(this, R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    /** ?list **/
    List<Fragment> fragmentList = new ArrayList<>();
    /** ?title list **/
    String[] array = getResources().getStringArray(R.array.array_language);
    List<String> titleList = Arrays.asList(array);
    for (String title : titleList) {
        fragmentList.add(MainFragment.getInstance(title));
    }
    viewPager.setAdapter(new MainPagerAdapter(getSupportFragmentManager(), fragmentList, titleList));
    viewPager.setOffscreenPageLimit(fragmentList.size());
}

From source file:ac.robinson.bettertogether.QRPopupWindow.java

void showPopUp() {
    // could use mPopupWindow.getMaxAvailableHeight() if only there was a width version!
    DisplayMetrics displayMetrics = new DisplayMetrics();
    mWindowManager.getDefaultDisplay().getMetrics(displayMetrics);
    int popupSize = (int) Math
            .round((displayMetrics.widthPixels > displayMetrics.heightPixels ? displayMetrics.heightPixels
                    : displayMetrics.widthPixels) * 0.9);

    // normally: WindowManager.LayoutParams.WRAP_CONTENT);
    mPopupWindow.setWidth(popupSize);/*from  www  . j  av a2 s .  c  om*/
    mPopupWindow.setHeight(popupSize);
    mPopupWindow.setTouchable(true);
    mPopupWindow.setFocusable(true);
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog);

    int elevation = mAnchorView.getContext().getResources().getDimensionPixelSize(R.dimen.default_elevation);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mPopupWindow.setElevation(elevation);
    }

    // display as popup overlaying anchor view - as 4dp elevation is same as horizontal offset, use that precalculated value
    PopupWindowCompat.setOverlapAnchor(mPopupWindow, true);
    PopupWindowCompat.showAsDropDown(mPopupWindow, mAnchorView, -elevation, 0, Gravity.TOP | Gravity.END);
}

From source file:com.grarak.rom.switcher.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  w  w  w.j a v  a  2s  .  c  o m

    progressBar = new ProgressBar(this);
    progressBar.getIndeterminateDrawable().setColorFilter(
            new LightingColorFilter(0xFF000000, getResources().getColor(android.R.color.white)));
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(progressBar, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END));

    new Task().execute();
}

From source file:com.daiv.android.twitter.listeners.InteractionClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    HoloTextView title = (HoloTextView) view.findViewById(R.id.title);
    String mTitle = title.getText().toString();

    HoloTextView text = (HoloTextView) view.findViewById(R.id.text);
    String mText = text.getText().toString();

    // get the datasource ready to read/write
    InteractionsDataSource data = InteractionsDataSource.getInstance(context);

    if (mTitle.contains(context.getResources().getString(R.string.mentioned_by))) { // this is a mention
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {
                @Override//from   w w w  .  j ava2s.c om
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.END);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, 300);

            viewPager.setCurrentItem((mentionsPage), true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.END);
            } catch (Exception e) {
                // landscape mode
            }
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Intent intent = new Intent(context, MainActivity.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    intent.putExtra("page_to_open", mentionsPage);
                    intent.putExtra("from_drawer", true);

                    sharedPreferences.edit().putBoolean("should_refresh", false).commit();

                    try {
                        Thread.sleep(400);
                    } catch (Exception e) {

                    }

                    try {
                        context.startActivity(intent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }).start();
        }
    } else if (mTitle.contains(context.getResources().getString(R.string.retweeted))
            || mTitle.contains(context.getResources().getString(R.string.favorited))
            || mTitle.contains(context.getResources().getString(R.string.quoted))
            || mTitle.contains(context.getResources().getString(R.string.new_favorites))
            || mTitle.contains(context.getResources().getString(R.string.new_retweets))
            || mTitle.contains(context.getResources().getString(R.string.new_quotes))) { // it is a retweet or favorite

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // open up the dialog with the users that retweeted it

        final String[] fItems = data
                .getUsers(sharedPreferences.getInt("current_account", 1), i,
                        DrawerActivity.oldInteractions.getText().toString()
                                .equals(context.getResources().getString(R.string.old_interactions)))
                .split(" ");

        LayoutInflater factory = LayoutInflater.from(context);
        View content = factory.inflate(R.layout.interaction_dialog, null);

        TextView textView = (TextView) content.findViewById(R.id.text);
        textView.setText(mText);

        ListView lv = (ListView) content.findViewById(R.id.list);
        lv.setAdapter(new ArrayAdapter<String>(context, android.R.layout.simple_selectable_list_item, fItems));

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setView(content);

        AlertDialog alert = builder.create();
        alert.show();
    } else if (mTitle.contains(context.getResources().getString(R.string.followed))) { // someone new followed you

        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
    } else if (mTitle.contains(context.getResources().getString(R.string.tweeted))) {
        try {
            drawer.closeDrawer(Gravity.END);
        } catch (Exception e) {
            // landscape mode
        }

        // a new follower, open up the followers profile
        String username = mTitle.substring(mTitle.indexOf("@") + 1, mTitle.indexOf(" "));
    }

    // mark it read in the sql database
    data.markRead(sharedPreferences.getInt("current_account", 1), i);

    // tell the system to refresh the notifications when the user opens the drawer again
    sharedPreferences.edit().putBoolean("new_notification", true).commit();
}