List of usage examples for android.view Gravity START
int START
To view the source code for android.view Gravity START.
Click Source Link
From source file:com.yoloo.android.util.ScrimUtil.java
/** * Creates an approximated cubic gradient using a multi-stop linear gradient. See * <a href="https://plus.google.com/+RomanNurik/posts/2QvHVFWrHZf">this post</a> for more * details./* w w w . j a v a 2s . c o m*/ */ public static Drawable makeCubicGradientScrimDrawable(int baseColor, int numStops, int gravity) { // Generate a cache key by hashing together the inputs, // based on the method described in the Effective Java book int cacheKeyHash = baseColor; cacheKeyHash = 31 * cacheKeyHash + numStops; cacheKeyHash = 31 * cacheKeyHash + gravity; Drawable cachedGradient = cubicGradientScrimCache.get(cacheKeyHash); if (cachedGradient != null) { return cachedGradient; } numStops = Math.max(numStops, 2); PaintDrawable paintDrawable = new PaintDrawable(); paintDrawable.setShape(new RectShape()); final int[] stopColors = new int[numStops]; final int red = Color.red(baseColor); final int green = Color.green(baseColor); final int blue = Color.blue(baseColor); final int alpha = Color.alpha(baseColor); for (int i = 0; i < numStops; i++) { float x = i * 1f / (numStops - 1); float opacity = MathUtils.constrain(0, 1, (float) Math.pow(x, 3)); stopColors[i] = Color.argb((int) (alpha * opacity), red, green, blue); } final float x0, x1, y0, y1; switch (gravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.START: x0 = 1; x1 = 0; break; case Gravity.END: x0 = 0; x1 = 1; break; default: x0 = 0; x1 = 0; break; } switch (gravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: y0 = 1; y1 = 0; break; case Gravity.BOTTOM: y0 = 0; y1 = 1; break; default: y0 = 0; y1 = 0; break; } paintDrawable.setShaderFactory(new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int width, int height) { return new LinearGradient(width * x0, height * y0, width * x1, height * y1, stopColors, null, Shader.TileMode.CLAMP); } }); cubicGradientScrimCache.put(cacheKeyHash, paintDrawable); return paintDrawable; }
From source file:com.heinrichreimersoftware.materialdrawer.DrawerFrameLayout.java
public DrawerFrameLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); inflate(context, R.layout.md_drawer_frame_layout, this); mDrawer = (DrawerView) findViewById(R.id.mdDrawer); setDrawerShadow(R.drawable.md_drawer_shadow, Gravity.START); TypedArray a = getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorPrimaryDark }); int colorPrimaryDark = a.getColor(0, 0); Log.d("fsgsdg", "colorPrimaryDark: " + colorPrimaryDark); if (colorPrimaryDark != 0) { setStatusBarBackgroundColor(colorPrimaryDark); } else {//w w w . ja v a2s .co m setStatusBarBackgroundColor(getResources().getColor(android.R.color.black)); } a = getContext().obtainStyledAttributes(attrs, new int[] { R.attr.drawerMaxWidth }); int drawerMaxWidth = a.getDimensionPixelSize(0, 0); Log.d("fsgsdg", "drawerMaxWidth: " + drawerMaxWidth); if (drawerMaxWidth != 0) { setDrawerMaxWidth(drawerMaxWidth); } else { resetDrawerMaxWidth(); } a.recycle(); }
From source file:de.dreier.mytargets.utils.SlideInItemAnimator.java
@Override public boolean animateAdd(RecyclerView.ViewHolder holder) { if (useDefaultAnimator) { return super.animateAdd(holder); }/* w ww. ja v a 2s . c om*/ holder.itemView.setAlpha(0f); switch (slideFromEdge) { case Gravity.START: holder.itemView.setTranslationX(-holder.itemView.getWidth() / 3); break; case Gravity.TOP: holder.itemView.setTranslationY(-holder.itemView.getHeight() / 3); break; case Gravity.END: holder.itemView.setTranslationX(holder.itemView.getWidth() / 3); break; default: // Gravity.BOTTOM holder.itemView.setTranslationY(holder.itemView.getHeight() / 3); } pendingAdds.add(holder); return true; }
From source file:com.antonioleiva.materialeverywhere.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/* w w w . ja v a 2 s.co m*/ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); }
From source file:material.example.raj.com.materialdesignexample.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setNavigationIcon(R.drawable.ic_drawer); if (toolbar != null) { setSupportActionBar(toolbar);//from www .ja v a 2 s .c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); } drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); mToggle = new ActionBarDrawerToggle(this, drawer, R.string.abc_action_bar_home_description, R.string.abc_action_bar_home_description); mToggle.setDrawerIndicatorEnabled(true); drawer.setDrawerListener(mToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); listSlideMenu = (ListView) findViewById(R.id.listSlideMenu); listSlideMenu.setAdapter(new SlideMenuAdapter(this)); listSlideMenu.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { displayView(position); } }); }
From source file:com.daiv.android.twitter.settings.SettingsDrawerClickListener.java
@Override public void onItemClick(AdapterView parent, View view, int position, long id) { new Handler().postDelayed(new Runnable() { @Override/* w w w. j av a 2 s . c o m*/ public void run() { mDrawerLayout.closeDrawer(Gravity.START); } }, 300); viewPager.setCurrentItem(position, true); }
From source file:com.example.android.support.transition.widget.ArcMotionUsage.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRoot = findViewById(R.id.root);/*from ww w . j a va 2 s. c om*/ mTarget = findViewById(R.id.target); mTransition = new ChangeBounds(); mTransition.setPathMotion(new ArcMotion()); mTransition.setInterpolator(new FastOutSlowInInterpolator()); mTransition.setDuration(500); findViewById(R.id.move).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TransitionManager.beginDelayedTransition(mRoot, mTransition); FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mTarget.getLayoutParams(); if ((lp.gravity & Gravity.START) == Gravity.START) { lp.gravity = Gravity.END | Gravity.BOTTOM; } else { lp.gravity = Gravity.START | Gravity.TOP; } mTarget.setLayoutParams(lp); } }); }
From source file:com.dev.demo.activities.SlidingActivity.java
private void configureToolbar() { Toolbar mainToolbar = (Toolbar) findViewById(R.id.activity_transition_header); setSupportActionBar(mainToolbar);/* w w w . ja va 2 s . c om*/ getSupportActionBar().setTitle("Sliding"); mainToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mDrawerLayout.isDrawerOpen(Gravity.START)) { mDrawerLayout.closeDrawer(Gravity.START); } else { mDrawerLayout.openDrawer(Gravity.START); } } }); }
From source file:com.daiv.android.twitter.settings.SettingsLinkDrawerClickListener.java
@Override public void onItemClick(AdapterView parent, View view, int position, long id) { Intent intent;/* www .j a v a2s . c o m*/ final int mPos = position; if (mPos < 2) { // one of the settings pages new Handler().postDelayed(new Runnable() { @Override public void run() { mDrawerLayout.closeDrawer(Gravity.START); } }, 300); viewPager.setCurrentItem(mPos + 7, true); } else if (mPos == 2) { // changelog final ListView list = new ListView(context); list.setDividerHeight(0); new AsyncTask<Spanned[], Void, Spanned[]>() { @Override public Spanned[] doInBackground(Spanned[]... params) { return XmlChangelogUtils.parse(context); } @Override public void onPostExecute(Spanned[] result) { list.setAdapter(new ChangelogAdapter(context, result)); } }.execute(); new AlertDialog.Builder(context).setTitle(R.string.changelog).setView(list) .setPositiveButton(R.string.ok, null).show(); } else if (mPos == 3) { // rate it option new Handler().postDelayed(new Runnable() { @Override public void run() { Uri uri = Uri.parse("market://details?id=" + context.getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); try { context.startActivity(goToMarket); } catch (ActivityNotFoundException e) { Toast.makeText(context, "Couldn't launch the market", Toast.LENGTH_SHORT).show(); } } }, 200); } }
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 w ww . ja v a 2s. c om throw new JSApplicationIllegalArgumentException("Unknown drawerPosition " + drawerPosition); } }