List of usage examples for android.view Gravity LEFT
int LEFT
To view the source code for android.view Gravity LEFT.
Click Source Link
From source file:cn.djangoogle.pull2load.internal.LoadingLayout.java
public LoadingLayout(Context context, final Mode mode, final Orientation scrollDirection, TypedArray attrs) { super(context); mMode = mode;//from w ww .j av a 2 s . com mScrollDirection = scrollDirection; switch (scrollDirection) { case HORIZONTAL: LayoutInflater.from(context).inflate(R.layout.pull2load_header_horizontal, this); break; case VERTICAL: default: LayoutInflater.from(context).inflate(R.layout.pull2load_header_vertical, this); break; } mInnerLayout = (FrameLayout) findViewById(R.id.fl_inner); mHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_text); mHeaderProgressWheel = (ProgressWheel) mInnerLayout.findViewById(R.id.pull_to_refresh_progress_wheel); mSubHeaderText = (TextView) mInnerLayout.findViewById(R.id.pull_to_refresh_sub_text); mHeaderImage = (ImageView) mInnerLayout.findViewById(R.id.pull_to_refresh_image); LayoutParams lp = (LayoutParams) mInnerLayout.getLayoutParams(); switch (mode) { case PULL_FROM_END: lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.TOP : Gravity.LEFT; // Load in labels mPullLabel = context.getString(R.string.pull_to_refresh_from_bottom_pull_label); mRefreshingLabel = context.getString(R.string.pull_to_refresh_from_bottom_refreshing_label); mReleaseLabel = context.getString(R.string.pull_to_refresh_from_bottom_release_label); break; case PULL_FROM_START: default: lp.gravity = scrollDirection == Orientation.VERTICAL ? Gravity.BOTTOM : Gravity.RIGHT; // Load in labels mPullLabel = context.getString(R.string.pull_to_refresh_pull_label); mRefreshingLabel = context.getString(R.string.pull_to_refresh_refreshing_label); mReleaseLabel = context.getString(R.string.pull_to_refresh_release_label); break; } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderBackground)) { Drawable background = attrs.getDrawable(R.styleable.PullToRefresh_ptrHeaderBackground); if (null != background) { ViewCompat.setBackground(this, background); } } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance)) { TypedValue styleID = new TypedValue(); attrs.getValue(R.styleable.PullToRefresh_ptrHeaderTextAppearance, styleID); setTextAppearance(styleID.data); } if (attrs.hasValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance)) { TypedValue styleID = new TypedValue(); attrs.getValue(R.styleable.PullToRefresh_ptrSubHeaderTextAppearance, styleID); setSubTextAppearance(styleID.data); } // Text Color attrs need to be set after TextAppearance attrs if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderTextColor)) { ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderTextColor); if (null != colors) { setTextColor(colors); } } if (attrs.hasValue(R.styleable.PullToRefresh_ptrHeaderSubTextColor)) { ColorStateList colors = attrs.getColorStateList(R.styleable.PullToRefresh_ptrHeaderSubTextColor); if (null != colors) { setSubTextColor(colors); } } // Try and get defined drawable from Attrs Drawable imageDrawable = null; if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawable)) { imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawable); } // Check Specific Drawable from Attrs, these overrite the generic // drawable attr above switch (mode) { case PULL_FROM_START: default: if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableStart)) { imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableStart); } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableTop)) { Pull2LoadCommonUtil.warnDeprecation("ptrDrawableTop", "ptrDrawableStart"); imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableTop); } break; case PULL_FROM_END: if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableEnd)) { imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableEnd); } else if (attrs.hasValue(R.styleable.PullToRefresh_ptrDrawableBottom)) { Pull2LoadCommonUtil.warnDeprecation("ptrDrawableBottom", "ptrDrawableEnd"); imageDrawable = attrs.getDrawable(R.styleable.PullToRefresh_ptrDrawableBottom); } break; } // If we don't have a user defined drawable, load the default if (null == imageDrawable) { imageDrawable = ContextCompat.getDrawable(context, getDefaultDrawableResId()); } // Set Drawable, and save width/height setLoadingDrawable(imageDrawable); reset(); }
From source file:com.aleiacampo.oristanobus.util.NavigationDrawerUtil.java
public static void setFavourites(final AppCompatActivity appCompatActivity) { final Bundle bundle = new Bundle(); final ArrayList<Stop> stopsList; SQLiteHelper db = new SQLiteHelper(appCompatActivity); stopsList = db.getAllStops();//from w w w. j a va 2s. c o m ArrayList<String> stopsNameList = new ArrayList<>(); for (Stop stop : stopsList) { stopsNameList.add(stop.nameStop); } if (stopsList.isEmpty()) stopsNameList.add("Nessuna fermata salvata"); ListView favourites = (ListView) appCompatActivity.findViewById(R.id.favourite_list); ArrayAdapter<String> adapter = new ArrayAdapter<>(appCompatActivity.getApplicationContext(), R.layout.text_view, stopsNameList); favourites.setAdapter(adapter); favourites.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { bundle.putInt("id_stop", stopsList.get(position).idStop); bundle.putInt("id_line", stopsList.get(position).idLine); bundle.putString("name_stop", stopsList.get(position).nameStop); bundle.putString("name_line", stopsList.get(position).nameLine); DrawerLayout drawer = (DrawerLayout) appCompatActivity.findViewById(R.id.drawer_left); drawer.closeDrawer(Gravity.LEFT); FragmentManager fragmentManager = appCompatActivity.getSupportFragmentManager(); TimesFragment timesFragment = new TimesFragment(); timesFragment.setArguments(bundle); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.home_frag, timesFragment, "Times"); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); } }); favourites.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, final int pos, long id) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(appCompatActivity); alertDialog.setMessage("Rimuovere la fermata dai preferiti?"); alertDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { SQLiteHelper db2 = new SQLiteHelper(appCompatActivity); db2.deleteStop(stopsList.get(pos).id); // l'id della fermata caricato dal db NavigationDrawerUtil.setFavourites(appCompatActivity); dialog.cancel(); } }); alertDialog.setNegativeButton("Nope !", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialog.show(); return true; } }); favourites.setLongClickable(true); }
From source file:com.dwdesign.tweetings.adapter.DirectMessagesConversationAdapter.java
@Override public void bindView(final View view, final Context context, final Cursor cursor) { final int position = cursor.getPosition(); final DirectMessageConversationViewHolder holder = (DirectMessageConversationViewHolder) view.getTag(); final long account_id = cursor.getLong(mIndices.account_id); final long message_timestamp = cursor.getLong(mIndices.message_timestamp); final long sender_id = cursor.getLong(mIndices.sender_id); final boolean is_outgoing = account_id == sender_id; final String name = mDisplayName ? cursor.getString(mIndices.sender_name) : cursor.getString(mIndices.sender_screen_name); holder.setTextSize(mTextSize);//from w w w .jav a 2s . c o m final TwidereLinkify linkify = new TwidereLinkify(holder.text); linkify.setOnLinkClickListener(new OnLinkClickHandler(context, account_id)); linkify.addAllLinks(); holder.text.setMovementMethod(null); holder.name.setText(name); holder.name.setGravity(is_outgoing ? Gravity.LEFT : Gravity.RIGHT); holder.text.setText(cursor.getString(mIndices.text)); holder.text.setGravity(is_outgoing ? Gravity.LEFT : Gravity.RIGHT); holder.time.setText(formatToLongTimeString(mContext, message_timestamp)); holder.time.setGravity(is_outgoing ? Gravity.RIGHT : Gravity.LEFT); holder.profile_image_left.setVisibility(mDisplayProfileImage && is_outgoing ? View.VISIBLE : View.GONE); holder.profile_image_right.setVisibility(mDisplayProfileImage && !is_outgoing ? View.VISIBLE : View.GONE); if (mDisplayProfileImage) { final String sender_profile_image_url_string = cursor.getString(mIndices.sender_profile_image_url); final URL sender_profile_image_url = parseURL( mDisplayHiResProfileImage ? getBiggerTwitterProfileImage(sender_profile_image_url_string) : sender_profile_image_url_string); mImageLoader.displayProfileImage(holder.profile_image_left, String.valueOf(sender_profile_image_url)); mImageLoader.displayProfileImage(holder.profile_image_right, String.valueOf(sender_profile_image_url)); holder.profile_image_left.setTag(position); holder.profile_image_right.setTag(position); } super.bindView(view, context, cursor); }
From source file:com.appsimobile.appsii.AbstractHotspotHelper.java
@SuppressWarnings("deprecation") protected WindowManager.LayoutParams createHotspotParams(HotspotItem conf, SharedPreferences prefs) { Display display = mWindowManager.getDefaultDisplay(); mHeight = display.getHeight();//from ww w . ja v a2s.com float pct = conf.mHeightRelativeToViewHeight; int realHeight = (int) (mHeight * pct); if (realHeight < mDp56) realHeight = mDp56; int y = (int) (conf.mYPosRelativeToView * mHeight); int hotspotWidth = prefs.getInt("pref_hotspot_width", 22); int width = (int) (hotspotWidth * AppsiApplication.getDensity(mContext)); int xOffset = 0; if (conf.mLeft) { WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); params.gravity = Gravity.LEFT | Gravity.TOP; params.x = xOffset; params.y = y; params.width = width; params.height = realHeight; return params; } else { WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); params.gravity = Gravity.RIGHT | Gravity.TOP; params.x = xOffset; params.y = y; params.width = width; params.height = realHeight; return params; } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.MusicObj.java
public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();//from w w w . ja v a 2 s .c om LinearLayout container = new LinearLayout(context); container.setLayoutParams(CommonLayouts.FULL_WIDTH); container.setOrientation(LinearLayout.HORIZONTAL); container.setGravity(Gravity.CENTER); ImageView imageView = new ImageView(context); imageView.setImageResource(R.drawable.play); imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); TextView valueTV = new TextView(context); valueTV.setText(asText(content)); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.BOTTOM | Gravity.LEFT); valueTV.setPadding(4, 0, 0, 0); container.addView(imageView); container.addView(valueTV); frame.addView(container); }
From source file:com.example.android.supportv7.app.ActionBarDisplayOptions.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;/* w w w .j av a2 s. co m*/ case R.id.toggle_show_home: flags = ActionBar.DISPLAY_SHOW_HOME; break; case R.id.toggle_use_logo: flags = ActionBar.DISPLAY_USE_LOGO; 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.toggle_navigation: bar.setNavigationMode( bar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD ? ActionBar.NAVIGATION_MODE_TABS : ActionBar.NAVIGATION_MODE_STANDARD); return; 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:android.support.v7.widget.AppCompatProgressBarHelper.java
/** * Converts a drawable to a tiled version of itself. It will recursively * traverse layer and state list drawables. *//*from w w w . jav a 2s .com*/ private Drawable tileify(Drawable drawable, boolean clip) { if (drawable instanceof DrawableWrapper) { Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable(); if (inner != null) { inner = tileify(inner, clip); ((DrawableWrapper) drawable).setWrappedDrawable(inner); } } else if (drawable instanceof LayerDrawable) { LayerDrawable background = (LayerDrawable) drawable; final int N = background.getNumberOfLayers(); Drawable[] outDrawables = new Drawable[N]; for (int i = 0; i < N; i++) { int id = background.getId(i); outDrawables[i] = tileify(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress)); } LayerDrawable newBg = new LayerDrawable(outDrawables); for (int i = 0; i < N; i++) { newBg.setId(i, background.getId(i)); } return newBg; } else if (drawable instanceof BitmapDrawable) { final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; final Bitmap tileBitmap = bitmapDrawable.getBitmap(); if (mSampleTile == null) { mSampleTile = tileBitmap; } final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape()); final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP); shapeDrawable.getPaint().setShader(bitmapShader); shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter()); return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable; } return drawable; }
From source file:brazole.com.secondtask.MainActivity.java
private void setNAvigationDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); mDrawerLayout.addDrawerListener(mDrawerToggle); mDrawerToggle.syncState();//from w w w . j a va 2s .com NavigationView mNavigationView = (NavigationView) findViewById(R.id.nav_view); mNavigationView.setNavigationItemSelectedListener(this); mDrawerToggle.setDrawerIndicatorEnabled(false); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mDrawerLayout.openDrawer(Gravity.LEFT); } }); }
From source file:com.facebook.notifications.internal.content.TextContent.java
@Override public void applyTo(@NonNull View view) { if (view instanceof TextView) { TextView textView = (TextView) view; textView.setText(getText());//from w w w. j a v a2s . co m textView.setTextColor(getTextColor()); Typeface typeface = FontUtilities.parseFont(getTypeface()); typeface = typeface != null ? typeface : Typeface.DEFAULT; textView.setTypeface(typeface); textView.setTextSize(getTypefaceSize()); switch (getTextAlignment()) { case Left: textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); break; case Center: textView.setGravity(Gravity.CENTER); break; case Right: textView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); break; } } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.JoinNotificationObj.java
@Override public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { TextView valueTV = new TextView(context); valueTV.setText("I'm here!"); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV);/* ww w .ja v a 2s. c o m*/ }