當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。