当前位置: 首页>>代码示例>>Java>>正文


Java GravityCompat类代码示例

本文整理汇总了Java中android.support.v4.view.GravityCompat的典型用法代码示例。如果您正苦于以下问题:Java GravityCompat类的具体用法?Java GravityCompat怎么用?Java GravityCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GravityCompat类属于android.support.v4.view包,在下文中一共展示了GravityCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDrawerShadow

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
/**
 * Set a simple drawable used for the left or right shadow.
 * The drawable provided must have a nonzero intrinsic width.
 *
 * @param shadowDrawable Shadow drawable to use at the edge of a drawer
 * @param gravity Which drawer the shadow should apply to
 */
public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity int gravity) {
      /*
       * TODO Someone someday might want to set more complex drawables here.
       * They're probably nuts, but we might want to consider registering callbacks,
       * setting states, etc. properly.
       */

  final int absGravity = GravityCompat.getAbsoluteGravity(gravity,
      ViewCompat.getLayoutDirection(this));
  if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
    mShadowLeft = shadowDrawable;
    invalidate();
  }
  if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
    mShadowRight = shadowDrawable;
    invalidate();
  }
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:26,代码来源:DebugDrawerLayout.java

示例2: onBackPressed

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@Override
public void onBackPressed() {
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        Fragment f = getSupportFragmentManager().findFragmentById(R.id.containerHome);
        if (f instanceof MapFragment) {
            super.onBackPressed();
        } else {
            if (getIntent().getExtras() != null && getIntent().getExtras().getString(EXTRA_DATA) != null) {
                finish();
            } else {
                navigationView.getMenu().getItem(0).setChecked(true);
                setTitleToolbar(getString(R.string.map_stations));
                getSupportFragmentManager().popBackStack("", FragmentManager.POP_BACK_STACK_INCLUSIVE);
            }
        }
    }
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:20,代码来源:HomeActivity.java

示例3: RecyclerViewScrollbar

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
public RecyclerViewScrollbar(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.RecyclerViewScrollbar, defStyleAttr, 0);
    mRecyclerViewId = ta.getResourceId(R.styleable.RecyclerViewScrollbar_recyclerView, 0);
    mScrollbarDrawable = ta.getDrawable(R.styleable.RecyclerViewScrollbar_scrollbarDrawable);
    mLetterDrawable = ta.getDrawable(R.styleable.RecyclerViewScrollbar_letterDrawable);
    int letterTextResId = ta.getResourceId(R.styleable.RecyclerViewScrollbar_letterTextAppearance, 0);
    mMinScrollbarHeight = ta.getDimensionPixelOffset(R.styleable.RecyclerViewScrollbar_minScrollbarHeight, 0);
    ta.recycle();

    mLetterView = new TextView(getContext());
    mLetterView.setBackgroundDrawable(mLetterDrawable);
    TextViewCompat.setTextAppearance(mLetterView, letterTextResId);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.gravity = GravityCompat.END;
    mLetterView.setLayoutParams(params);
    mLetterView.setGravity(Gravity.CENTER);
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:21,代码来源:RecyclerViewScrollbar.java

示例4: setupViewsForKey

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
public void setupViewsForKey(Key key, View newView) {
    if(key.shouldShowUp()) {
        setDrawerLockMode(LOCK_MODE_LOCKED_CLOSED, GravityCompat.START);
        drawerToggle.setDrawerIndicatorEnabled(false);
        MainActivity.get(getContext()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    } else {
        setDrawerLockMode(LOCK_MODE_UNLOCKED, GravityCompat.START);
        MainActivity.get(getContext()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        drawerToggle.setDrawerIndicatorEnabled(true);
    }
    drawerToggle.syncState();
    setCheckedItem(key.navigationViewId());
    MainActivity.get(getContext()).supportInvalidateOptionsMenu();
    if(key.isFabVisible()) {
        fabAddTask.setVisibility(View.VISIBLE);
    } else {
        fabAddTask.setVisibility(View.GONE);
    }
    fabAddTask.setOnClickListener(key.fabClickListener(newView));
    if(key.fabDrawableIcon() != 0) {
        fabAddTask.setImageResource(key.fabDrawableIcon());
    }
}
 
开发者ID:Zhuinden,项目名称:navigator,代码行数:24,代码来源:MainView.java

示例5: showIndicator

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
public void showIndicator(View parent, Rect touchBounds) {
    if (isShowing()) {
        mPopupView.mMarker.animateOpen();
        return;
    }

    IBinder windowToken = parent.getWindowToken();
    if (windowToken != null) {
        WindowManager.LayoutParams p = createPopupLayout(windowToken);

        p.gravity = Gravity.TOP | GravityCompat.START;
        updateLayoutParamsForPosiion(parent, p, touchBounds.bottom);
        mShowing = true;

        translateViewIntoPosition(touchBounds.centerX());
        invokePopup(p);
    }
}
 
开发者ID:dmllr,项目名称:IdealMedia,代码行数:19,代码来源:PopupIndicator.java

示例6: onBackPressed

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        // back to all groups
        // super.onBackPressed();
        if (statusToShow != null) {
            Log.w("true", statusToShow.toString());
            Intent intent = new Intent(this, UserGroupLessonsActivity.class);
            startActivity(intent);
        } else {
            Log.w("false", "false");
            super.onBackPressed();
        }
    }
}
 
开发者ID:white-collar,项目名称:mobile-grammar,代码行数:19,代码来源:AllArticlesListViewActivity.java

示例7: onNavigationItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_settings) {

    } else if (id == R.id.nav_about) {
        Intent intent = new Intent(this, OssLicensesMenuActivity.class);
        String title = getString(R.string.license_screen_title);
        intent.putExtra("title", title);
        startActivity(intent);
        return true;
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return super.onOptionsItemSelected(item);
}
 
开发者ID:barnhill,项目名称:SimpleBible,代码行数:21,代码来源:MainActivity.java

示例8: applyModeAndGravity

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
private void applyModeAndGravity() {
  int paddingStart = 0;
  if (mMode == MODE_SCROLLABLE) {
    // If we're scrollable, or fixed at start, inset using padding
    paddingStart = Math.max(0, mContentInsetStart - mTabPaddingStart);
  }
  ViewCompat.setPaddingRelative(mTabStrip, paddingStart, 0, 0, 0);

  switch (mMode) {
    case MODE_FIXED:
      mTabStrip.setGravity(Gravity.CENTER_HORIZONTAL);
      break;
    case MODE_SCROLLABLE:
      mTabStrip.setGravity(GravityCompat.START);
      break;
  }

  updateTabViews(true);
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:20,代码来源:TabLayout.java

示例9: onNavigationItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_camera) {
        // Handle the camera action
    } else if (id == R.id.nav_gallery) {

    } else if (id == R.id.nav_slideshow) {

    } else if (id == R.id.nav_manage) {

    } else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:AlawnXu,项目名称:XMLBaseParser,代码行数:25,代码来源:MainActivity.java

示例10: onOptionsItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

        case R.id.backup:
            Toast.makeText(this, "well, you clicked Backup", Toast.LENGTH_SHORT).show();
            break;
        case R.id.about:
            showToast("Software Copyright Reserved ");

            break;
        case android.R.id.home:
            mDrawerLayout.openDrawer(GravityCompat.START);
            break;
        case R.id.settings: //写个新的activity关于
            Intent intent1 = new Intent(this, SettingActivity.class);
            startActivity(intent1);
            break;

        default:
            break;
    }
    return true;
}
 
开发者ID:MoonRiser,项目名称:MaterialLearning,代码行数:24,代码来源:MainActivity.java

示例11: onNavigationItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("active_switch", false)) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }
    if (id == R.id.nav_map) {
        itemSelected = 0;
        setTitleToolbar(getString(R.string.map_stations));
        getSupportFragmentManager().popBackStack("", FragmentManager.POP_BACK_STACK_INCLUSIVE);
    } else {
        if (checkIfItsLogged(id)) {
            showFragment(id);
        } else {
            navigationView.getMenu().getItem(itemSelected).setChecked(true);
            showLoginDialog();
        }
    }
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:Mun0n,项目名称:MADBike,代码行数:25,代码来源:HomeActivity.java

示例12: onNavigationItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_logout) {
        editor.putString("user_id", null);
        editor.putString("user_token", null);
        editor.putString("user_name", null);
        AppController.USER_ID = null;
        AppController.USER_TOKEN = null;
        AppController.USER_NAME = null;
        editor.commit();
        finish();
        startActivity(new Intent(ActivityMain.this, ActivityLaunchScreen_.class));
    }

    drawerLayout.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:lecrec,项目名称:lecrec-android,代码行数:22,代码来源:ActivityMain.java

示例13: onNavigationItemSelected

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.nav_home) {
        changePosts(POSTS_ACTIVE);
    } else if (id == R.id.nav_archived) {
        changePosts(POSTS_ARCHIVED);
    } else if (id == R.id.nav_favourites) {
        changePosts(POSTS_FAVOURITES);
    } else if (id == R.id.nav_settings) {
        startActivity(new Intent(App.getAppContext(),Settings.class));
    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:21,代码来源:MainActivity.java

示例14: toggle

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
private void toggle() {
    int drawerLockMode = this.mDrawerLayout.getDrawerLockMode((int) GravityCompat.START);
    if (this.mDrawerLayout.isDrawerVisible((int) GravityCompat.START) && drawerLockMode != 2) {
        this.mDrawerLayout.closeDrawer((int) GravityCompat.START);
    } else if (drawerLockMode != 1) {
        this.mDrawerLayout.openDrawer((int) GravityCompat.START);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:ActionBarDrawerToggle.java

示例15: onBackPressed

import android.support.v4.view.GravityCompat; //导入依赖的package包/类
@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}
 
开发者ID:OlgaKuklina,项目名称:GitJourney,代码行数:10,代码来源:MainActivity.java


注:本文中的android.support.v4.view.GravityCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。