Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

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

Prototype

int LEFT

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

Click Source Link

Document

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

Usage

From source file:com.jauker.badgeview.example.ViewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_views, null);

    View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault);
    backgroundDefaultBadge = new BadgeView(getActivity());
    backgroundDefaultBadge.setBadgeCount(42);
    backgroundDefaultBadge.setTargetView(backgroundDefaultView);

    View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable);
    backgroundDrawableBadge = new BadgeView(getActivity());
    backgroundDrawableBadge.setBadgeCount(88);
    backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue);
    backgroundDrawableBadge.setTargetView(backgroundDrawableView);

    View backgroundShapeView = layout.findViewById(R.id.backgroundShape);
    backgroundShapeBadge = new BadgeView(getActivity());
    backgroundShapeBadge.setBadgeCount(47);
    backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef"));
    backgroundShapeBadge.setTargetView(backgroundShapeView);

    View counterView = layout.findViewById(R.id.counter);
    counterView.setOnClickListener(this);
    counterBadge = new BadgeView(getActivity());
    counterBadge.setBadgeCount(-2);//from w ww.  j a  v a2  s .  c o m
    counterBadge.setTargetView(counterView);

    View gravityView = layout.findViewById(R.id.gravity);
    gravityView.setOnClickListener(this);
    gravityBadge = new BadgeView(getActivity());
    gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
    gravityBadge.setBadgeCount(4);
    gravityBadge.setTargetView(gravityView);

    View textStyleView = layout.findViewById(R.id.textStyle);
    textStyleView.setOnClickListener(this);
    textStyleBadge = new BadgeView(getActivity());
    textStyleBadge.setBadgeCount(18);
    textStyleBadge.setTargetView(textStyleView);
    textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
    textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN);

    View visibilityView = layout.findViewById(R.id.visibility);
    visibilityView.setOnClickListener(this);
    visibilityBadgeView = new BadgeView(getActivity());
    visibilityBadgeView.setBadgeCount(1);
    visibilityBadgeView.setTargetView(visibilityView);

    return layout;
}

From source file:com.ayoview.sample.textview.badge.ViewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.badge_fragment_views, null);

    View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault);
    backgroundDefaultBadge = new BadgeView(getActivity());
    backgroundDefaultBadge.setBadgeCount(42);
    backgroundDefaultBadge.setTargetView(backgroundDefaultView);

    View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable);
    backgroundDrawableBadge = new BadgeView(getActivity());
    backgroundDrawableBadge.setBadgeCount(88);
    backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue);
    backgroundDrawableBadge.setTargetView(backgroundDrawableView);

    View backgroundShapeView = layout.findViewById(R.id.backgroundShape);
    backgroundShapeBadge = new BadgeView(getActivity());
    backgroundShapeBadge.setBadgeCount(47);
    backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef"));
    backgroundShapeBadge.setTargetView(backgroundShapeView);

    View counterView = layout.findViewById(R.id.counter);
    counterView.setOnClickListener(this);
    counterBadge = new BadgeView(getActivity());
    counterBadge.setBadgeCount(-2);/*from  www .j  a v  a2  s.  c o m*/
    counterBadge.setTargetView(counterView);

    View gravityView = layout.findViewById(R.id.gravity);
    gravityView.setOnClickListener(this);
    gravityBadge = new BadgeView(getActivity());
    gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
    gravityBadge.setBadgeCount(4);
    gravityBadge.setTargetView(gravityView);

    View textStyleView = layout.findViewById(R.id.textStyle);
    textStyleView.setOnClickListener(this);
    textStyleBadge = new BadgeView(getActivity());
    textStyleBadge.setBadgeCount(18);
    textStyleBadge.setTargetView(textStyleView);
    textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
    textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN);

    View visibilityView = layout.findViewById(R.id.visibility);
    visibilityView.setOnClickListener(this);
    visibilityBadgeView = new BadgeView(getActivity());
    visibilityBadgeView.setBadgeCount(1);
    visibilityBadgeView.setTargetView(visibilityView);

    return layout;
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * toolBar
 * @return
 */
protected RelativeLayout buildToolbarLayout() {
    return createToolbarLayout(Gravity.LEFT, Gravity.TOP);
}

From source file:com.apprevelations.Cozzy.FoldingDrawerLayout.java

boolean isDrawerView2(View child) {
    final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(child));
    return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
}

From source file:am.project.x.business.drawables.cornerdrawable.CornerDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override//from  w w  w  .  j a v  a 2 s .co  m
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (parent.getId()) {
    case R.id.cnd_sp_direction:
        switch (position) {
        default:
        case 0:
            drawable.setDirection(Gravity.TOP);
            break;
        case 1:
            drawable.setDirection(Gravity.LEFT);
            break;
        case 2:
            drawable.setDirection(Gravity.RIGHT);
            break;
        case 3:
            drawable.setDirection(Gravity.BOTTOM);
            break;
        }
        break;
    case R.id.cnd_sp_location:
        switch (position) {
        default:
        case 0:
            drawable.setLocation(Gravity.CENTER);
            break;
        case 1:
            drawable.setLocation(Gravity.LEFT);
            break;
        case 2:
            drawable.setLocation(Gravity.RIGHT);
            break;
        }
        break;
    }
}

From source file:arun.com.chromer.webheads.ui.views.Trashy.java

@SuppressLint("RtlHardcoded")
private void setInitialLocation() {
    final DisplayMetrics metrics = new DisplayMetrics();
    windowManager.getDefaultDisplay().getMetrics(metrics);
    dispWidth = metrics.widthPixels;/*ww  w  . jav a  2 s  . co m*/
    dispHeight = metrics.heightPixels;

    createWindowParams();

    windowParams.gravity = Gravity.LEFT | Gravity.TOP;
    int offset = getAdaptWidth() / 2;
    windowParams.x = (dispWidth / 2) - offset;
    windowParams.y = dispHeight - (dispHeight / 6) - offset;
}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * ButtonContainer//from  w  ww .ja  va2  s .  c om
 * @return
 */
protected RelativeLayout buildActionButtonContainerLayout() {
    return createActionButtonContainer(BUTTON_CONTAINER_ID,
            new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT), Gravity.LEFT,
            Gravity.CENTER_VERTICAL);
}

From source file:by.onliner.news.activity.MainActivity.java

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

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  w  w  w  .  ja va2  s  .c o m

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    mDrawerLayout.addDrawerListener(toggle);
    mDrawerLayout.addDrawerListener(this);
    toggle.syncState();

    mNavigationView = (NavigationView) findViewById(R.id.nav_view);
    mNavigationView.setNavigationItemSelectedListener(this);

    View headerNavigationView = mNavigationView.getHeaderView(0);

    mButtonAuth = (Button) headerNavigationView.findViewById(R.id.bt_auth_account);
    mButtonAuth.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            Intent intent = new Intent(App.getContext(), AuthActivity.class);
            startActivity(intent);
        }
    });

    mButtonLogout = (Button) headerNavigationView.findViewById(R.id.bt_logout_account);
    mButtonLogout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mDrawerLayout.closeDrawer(Gravity.LEFT);
            App.logoutUser();
            updateNavBarLoginInfo();
        }
    });

    mImageViewNavBarAvatar = (ImageView) headerNavigationView.findViewById(R.id.img_nav_header_avatar);
    mTextViewNavBarUsername = (TextView) headerNavigationView.findViewById(R.id.tv_nav_bar_username);

    updateNavBarLoginInfo();

    mTitles = new CharSequence[] { getString(R.string.tabAuto), getString(R.string.tabPeoples),
            getString(R.string.tabRealt), getString(R.string.tabTechnologies) };

    mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), mTitles, Numboftabs);

    mPager = (ViewPager) findViewById(R.id.pager_news_list);
    mPager.setOffscreenPageLimit(1);
    mPager.setAdapter(mAdapter);

    mTabs = (TabLayout) findViewById(R.id.tabs_news_list);
    mTabs.setupWithViewPager(mPager);
}

From source file:com.example.android.supportv7.app.ToolbarDisplayOptions.java

@Override
public void onClick(View v) {
    final ActionBar bar = getSupportActionBar();
    int flags = 0;
    switch (v.getId()) {
    case R.id.toggle_home_as_up:
        flags = ActionBar.DISPLAY_HOME_AS_UP;
        break;// ww  w. j  a v a 2  s  . c  o m
    case R.id.toggle_show_home:
        flags = ActionBar.DISPLAY_SHOW_HOME;
        break;
    case R.id.toggle_use_logo:
        flags = ActionBar.DISPLAY_USE_LOGO;
        getSupportActionBar().setLogo(R.drawable.ic_media_play);
        break;
    case R.id.toggle_show_title:
        flags = ActionBar.DISPLAY_SHOW_TITLE;
        break;
    case R.id.toggle_show_custom:
        flags = ActionBar.DISPLAY_SHOW_CUSTOM;
        break;
    case R.id.cycle_custom_gravity: {
        ActionBar.LayoutParams lp = mCustomViewLayoutParams;
        int newGravity = 0;
        switch (lp.gravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
        case Gravity.LEFT:
            newGravity = Gravity.CENTER_HORIZONTAL;
            break;
        case Gravity.CENTER_HORIZONTAL:
            newGravity = Gravity.RIGHT;
            break;
        case Gravity.RIGHT:
            newGravity = Gravity.LEFT;
            break;
        }
        lp.gravity = lp.gravity & ~Gravity.HORIZONTAL_GRAVITY_MASK | newGravity;
        bar.setCustomView(mCustomView, lp);
        return;
    }
    case R.id.toggle_visibility:
        if (bar.isShowing()) {
            bar.hide();
        } else {
            bar.show();
        }
        return;
    }

    int change = bar.getDisplayOptions() ^ flags;
    bar.setDisplayOptions(change, flags);
}

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

@Override
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*  w  w  w .jav  a2  s  .co m*/

    TextView valueTV = new TextView(context);
    valueTV.setText("Join me in '" + content.optString(GROUP_NAME) + "'");
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    frame.addView(valueTV);
}