List of usage examples for android.view Gravity TOP
int TOP
To view the source code for android.view Gravity TOP.
Click Source Link
From source file:ac.robinson.mediaphone.activity.TemplateBrowserActivity.java
private void initialiseTemplatesView() { mTemplates = (NarrativesListView) findViewById(R.id.list_templates); // for API 11 and above, buttons are in the action bar if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { LayoutInflater layoutInflater = getLayoutInflater(); View headerRow = layoutInflater.inflate(R.layout.templates_header, null, false); mTemplates.addHeaderView(headerRow, null, false); // false = not selectable View emptyView = layoutInflater.inflate(R.layout.templates_empty, null, false); ((ViewGroup) mTemplates.getParent()).addView(emptyView); mTemplates.setEmptyView(emptyView); // must add separately as the header isn't shown when empty } else {// w w w .j a va 2 s. c o m // initial empty list placeholder - add manually as the < v11 version includes the header row TextView emptyView = new TextView(TemplateBrowserActivity.this); emptyView.setGravity(Gravity.CENTER | Gravity.TOP); emptyView.setPadding(10, getResources().getDimensionPixelSize(R.dimen.template_list_empty_hint_top_padding), 10, 10); // temporary emptyView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); emptyView.setText(getString(R.string.template_list_empty)); ((ViewGroup) mTemplates.getParent()).addView(emptyView); mTemplates.setEmptyView(emptyView); } mTemplateAdapter = new NarrativeAdapter(this, false, true); mTemplates.setAdapter(mTemplateAdapter); getSupportLoaderManager().initLoader(R.id.loader_templates_completed, null, this); mTemplates.setOnScrollListener(new ScrollManager()); mTemplates.setOnTouchListener(new FingerTracker()); mTemplates.setOnItemSelectedListener(new SelectionTracker()); mTemplates.setOnItemClickListener(new NarrativeViewer()); }
From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java
private void setSelectorAttrs() { FrameLayout.LayoutParams selectorParams = (FrameLayout.LayoutParams) selectorContainer.getLayoutParams(); FrameLayout.LayoutParams bottomLineParams = (FrameLayout.LayoutParams) v_bottomLine.getLayoutParams(); if (selectorBringToFront) selectorContainer.bringToFront(); if (!selectorFullSize) selectorParams.height = selectorSize; int topMargin = 0, bottomMargin = 0; if (selectorTop) { selectorParams.gravity = Gravity.TOP; bottomLineParams.gravity = Gravity.TOP; topMargin = bottomLineSize;/*from www. j a v a2 s .com*/ } else if (selectorBottom) { selectorParams.gravity = Gravity.BOTTOM; bottomLineParams.gravity = Gravity.BOTTOM; bottomMargin = bottomLineSize; } if (selectorAboveOfBottomLine) { selectorParams.setMargins(0, topMargin, 0, bottomMargin); } }
From source file:android.support.transition.Slide.java
/** * Change the edge that Views appear and disappear from. * * @param slideEdge The edge of the scene to use for Views appearing and disappearing. One of * {@link android.view.Gravity#LEFT}, {@link android.view.Gravity#TOP}, * {@link android.view.Gravity#RIGHT}, {@link android.view.Gravity#BOTTOM}, * {@link android.view.Gravity#START}, {@link android.view.Gravity#END}. *///from w w w .j a v a 2 s . com public void setSlideEdge(@GravityFlag int slideEdge) { switch (slideEdge) { case Gravity.LEFT: mSlideCalculator = sCalculateLeft; break; case Gravity.TOP: mSlideCalculator = sCalculateTop; break; case Gravity.RIGHT: mSlideCalculator = sCalculateRight; break; case Gravity.BOTTOM: mSlideCalculator = sCalculateBottom; break; case Gravity.START: mSlideCalculator = sCalculateStart; break; case Gravity.END: mSlideCalculator = sCalculateEnd; break; default: throw new IllegalArgumentException("Invalid slide direction"); } mSlideEdge = slideEdge; SidePropagation propagation = new SidePropagation(); propagation.setSide(slideEdge); setPropagation(propagation); }
From source file:com.android.jhansi.designchallenge.NavigationDrawerActivity.java
private void showCustomToast(int resId) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.custom_toast, (ViewGroup) findViewById(R.id.custom_toast_layout)); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(resId);/*from w ww .j a va2s. co m*/ Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.TOP, 0, -1); toast.setDuration(Toast.LENGTH_SHORT); toast.setView(layout); toast.show(); }
From source file:com.master.metehan.filtereagle.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); Util.logExtras(getIntent());/*from ww w. j a va 2 s. c o m*/ if (Build.VERSION.SDK_INT < MIN_SDK) { super.onCreate(savedInstanceState); setContentView(R.layout.android); return; } Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.main); running = true; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean enabled = prefs.getBoolean("enabled", false); boolean initialized = prefs.getBoolean("initialized", false); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("registered", true).commit(); editor.putBoolean("logged", false).commit(); prefs.edit().remove("hint_system").apply(); // Register app String key = this.getString(R.string.app_key); String server_url = this.getString(R.string.serverurl); Register register = new Register(server_url, key, getApplicationContext()); register.registerApp(); // Upgrade Receiver.upgrade(initialized, this); if (!getIntent().hasExtra(EXTRA_APPROVE)) { if (enabled) ServiceSinkhole.start("UI", this); else ServiceSinkhole.stop("UI", this); } // Action bar final View actionView = getLayoutInflater().inflate(R.layout.actionmain, null, false); ivIcon = (ImageView) actionView.findViewById(R.id.ivIcon); ivQueue = (ImageView) actionView.findViewById(R.id.ivQueue); swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered); // Icon ivIcon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { menu_about(); return true; } }); // Title getSupportActionBar().setTitle(null); // Netguard is busy ivQueue.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_queue, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivQueue.getLeft(), Math.round(location[1] + ivQueue.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); // On/off switch swEnabled.setChecked(enabled); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.i(TAG, "Switch=" + isChecked); prefs.edit().putBoolean("enabled", isChecked).apply(); if (isChecked) { try { final Intent prepare = VpnService.prepare(ActivityMain.this); if (prepare == null) { Log.i(TAG, "Prepare done"); onActivityResult(REQUEST_VPN, RESULT_OK, null); } else { // Show dialog LayoutInflater inflater = LayoutInflater.from(ActivityMain.this); View view = inflater.inflate(R.layout.vpn, null, false); dialogVpn = new AlertDialog.Builder(ActivityMain.this).setView(view) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) { Log.i(TAG, "Start intent=" + prepare); try { // com.android.vpndialogs.ConfirmDialog required startActivityForResult(prepare, REQUEST_VPN); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); onActivityResult(REQUEST_VPN, RESULT_CANCELED, null); prefs.edit().putBoolean("enabled", false).apply(); } } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogVpn = null; } }).create(); dialogVpn.show(); } } catch (Throwable ex) { // Prepare failed Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); prefs.edit().putBoolean("enabled", false).apply(); } } else ServiceSinkhole.stop("switch off", ActivityMain.this); } }); if (enabled) checkDoze(); // Network is metered ivMetered.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivMetered.getLeft(), Math.round(location[1] + ivMetered.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); // Disabled warning TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE); // Application list RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication); rvApplication.setHasFixedSize(true); rvApplication.setLayoutManager(new LinearLayoutManager(this)); adapter = new AdapterRule(this); rvApplication.setAdapter(adapter); // Swipe to refresh TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setProgressBackgroundColorSchemeColor(tv.data); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Rule.clearCache(ActivityMain.this); ServiceSinkhole.reload("pull", ActivityMain.this); updateApplicationList(null); } }); final LinearLayout llSystem = (LinearLayout) findViewById(R.id.llSystem); Button btnSystem = (Button) findViewById(R.id.btnSystem); boolean system = prefs.getBoolean("manage_system", false); boolean hint = prefs.getBoolean("hint_system", true); llSystem.setVisibility(!system && hint ? View.VISIBLE : View.GONE); btnSystem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { prefs.edit().putBoolean("hint_system", false).apply(); llSystem.setVisibility(View.GONE); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); // Listen for rule set changes IntentFilter ifr = new IntentFilter(ACTION_RULES_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onRulesChanged, ifr); // Listen for queue changes IntentFilter ifq = new IntentFilter(ACTION_QUEUE_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onQueueChanged, ifq); // Listen for added/removed applications IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); registerReceiver(packageChangedReceiver, intentFilter); // First use if (!initialized) { // Create view LayoutInflater inflater = LayoutInflater.from(this); View view = inflater.inflate(R.layout.first, null, false); TextView tvFirst = (TextView) view.findViewById(R.id.tvFirst); tvFirst.setMovementMethod(LinkMovementMethod.getInstance()); // Show dialog dialogFirst = new AlertDialog.Builder(this).setView(view).setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) prefs.edit().putBoolean("initialized", true).apply(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) finish(); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogFirst = null; } }).create(); dialogFirst.show(); } // Fill application list updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); // Update IAB SKUs try { iab = new IAB(new IAB.Delegate() { @Override public void onReady(IAB iab) { try { iab.updatePurchases(); if (!IAB.isPurchased(ActivityPro.SKU_LOG, ActivityMain.this)) prefs.edit().putBoolean("log", false).apply(); if (!IAB.isPurchased(ActivityPro.SKU_THEME, ActivityMain.this)) { if (!"teal".equals(prefs.getString("theme", "teal"))) prefs.edit().putString("theme", "teal").apply(); } if (!IAB.isPurchased(ActivityPro.SKU_SPEED, ActivityMain.this)) prefs.edit().putBoolean("show_stats", false).apply(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } finally { iab.unbind(); } } }, this); iab.bind(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } checkExtras(getIntent()); }
From source file:com.iangclifton.android.floatlabel.FloatLabel.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void layoutChild(View child, int parentLeft, int parentTop, int parentRight, int parentBottom) { if (child.getVisibility() != GONE) { final LayoutParams lp = (LayoutParams) child.getLayoutParams(); final int width = child.getMeasuredWidth(); final int height = child.getMeasuredHeight(); int childLeft; final int childTop = parentTop + lp.topMargin; int gravity = lp.gravity; if (gravity == -1) { gravity = Gravity.TOP | Gravity.START; }//from ww w.ja va2 s .co m final int layoutDirection; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { layoutDirection = LAYOUT_DIRECTION_LTR; } else { layoutDirection = getLayoutDirection(); } final int absoluteGravity = GravityCompat.getAbsoluteGravity(gravity, layoutDirection); switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: childLeft = parentLeft + (parentRight - parentLeft - width) / 2 + lp.leftMargin - lp.rightMargin; break; case Gravity.RIGHT: childLeft = parentRight - width - lp.rightMargin; break; case Gravity.LEFT: default: childLeft = parentLeft + lp.leftMargin; } child.layout(childLeft, childTop, childLeft + width, childTop + height); } }
From source file:com.skyousuke.ivtool.windows.MainWindow.java
@SuppressLint("InflateParams") public MainWindow(final Context context, WindowManager windowManager, Handler handler) { this.context = context; this.windowManager = windowManager; this.handler = handler; inputData.setListener(this); layout = (CustomRelativeLayout) LayoutInflater.from(context).inflate(R.layout.tool_window, null); pokemonView = (AutoCompleteTextView) layout.findViewById(R.id.pokemon); dustView = (AutoCompleteTextView) layout.findViewById(R.id.dust); cpView = (AutoCompleteTextView) layout.findViewById(R.id.cp); hpView = (AutoCompleteTextView) layout.findViewById(R.id.hp); maxIVTextView = (TextView) layout.findViewById(R.id.max_iv); minIVTextView = (TextView) layout.findViewById(R.id.min_iv); final CheckBox powerUpCheck = (CheckBox) layout.findViewById(R.id.check_powered); TextView textCheck = (TextView) layout.findViewById(R.id.powered); message = (TextView) layout.findViewById(R.id.message); pokemonValidation = (ImageView) layout.findViewById(R.id.image_validation_pokemon); dustValidation = (ImageView) layout.findViewById(R.id.image_validation_dust); cpValidation = (ImageView) layout.findViewById(R.id.image_validation_cp); hpValidation = (ImageView) layout.findViewById(R.id.image_validation_hp); powerUpValidation = (ImageView) layout.findViewById(R.id.image_validation_power_up); seeResultButton = (Button) layout.findViewById(R.id.button_tool); appraisalButton = (Button) layout.findViewById(R.id.button_appraisal); appraisalLayout = (LinearLayout) layout.findViewById(R.id.appraisal); teamSelectLayout = (LinearLayout) layout.findViewById(R.id.team_select); teamSpinner = (Spinner) teamSelectLayout.findViewById(R.id.spinner_team); rangePhraseSpinner = (Spinner) layout.findViewById(R.id.spinner_iv_phrase); statPhraseSpinner = (Spinner) layout.findViewById(R.id.spinner_stats_phrase); appraisalWrong = (TextView) layout.findViewById(R.id.appraisal_wrong); layoutParams.gravity = Gravity.TOP | Gravity.CENTER; enableBackKey(true);/* w w w .j av a2 s . c o m*/ setTouchListener(); pokemonView.setAdapter(new ArrayAdapter<>(context, R.layout.simple_dropdown, Pokemon.values)); pokemonView.addTextChangedListener(new DefaultTextChangedListener() { @Override public void afterTextChanged(Editable editable) { inputData.setPokemon(editable.toString()); updateValidation(); } }); pokemonView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> p, View v, int pos, long id) { if (inputData.isDustUnset()) focusDustView(); } }); pokemonView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { pokemonView.setText(""); } } }); pokemonView.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { focusDustView(); return true; } return false; } }); dustView.setAdapter(new ArrayAdapter<>(context, R.layout.simple_dropdown, IVCalculator.dustList)); dustView.addTextChangedListener(new DefaultTextChangedListener() { @Override public void afterTextChanged(Editable editable) { inputData.setDust(editable.toString()); updateValidation(); } }); dustView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> p, View v, int pos, long id) { if (inputData.isCpUnset()) focusCpView(); } }); dustView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { dustView.setText(""); } } }); dustView.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { focusCpView(); return true; } return false; } }); cpView.addTextChangedListener(new DefaultTextChangedListener() { @Override public void afterTextChanged(Editable editable) { inputData.setCp(editable.toString()); updateValidation(); } }); cpView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> p, View v, int pos, long id) { if (inputData.isHpUnset()) focusHpView(); } }); cpView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { cpView.setText(""); } } }); cpView.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { focusHpView(); return true; } return false; } }); hpView.addTextChangedListener(new DefaultTextChangedListener() { @Override public void afterTextChanged(Editable editable) { inputData.setHp(editable.toString()); updateValidation(); } }); hpView.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean hasFocus) { if (hasFocus) { hpView.setText(""); } } }); powerUpCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { inputData.setPoweredUp(isChecked); updateValidation(); } }); textCheck.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { powerUpCheck.toggle(); } }); seeResultButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (resultWindow != null) { resultWindow.show(); enableBackKey(false); } } }); hideAppraisal(); }
From source file:android.support.v7ox.view.menu.ActionMenuItemView.java
@Override public boolean onLongClick(View v) { if (hasText()) { // Don't show the cheat sheet for items that already show text. return false; }//www . j ava 2s . c o m final int[] screenPos = new int[2]; final Rect displayFrame = new Rect(); getLocationOnScreen(screenPos); getWindowVisibleDisplayFrame(displayFrame); final Context context = getContext(); final int width = getWidth(); final int height = getHeight(); final int midy = screenPos[1] + height / 2; int referenceX = screenPos[0] + width / 2; if (ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_LTR) { final int screenWidth = context.getResources().getDisplayMetrics().widthPixels; referenceX = screenWidth - referenceX; // mirror } Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT); if (midy < displayFrame.height()) { // Show along the top; follow action buttons cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, screenPos[1] + height - displayFrame.top); } else { // Show along the bottom center cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height); } cheatSheet.show(); return true; }
From source file:com.moods_final.moods.entertainment.VideoListDemoActivity.java
/** * Sets up the layout programatically for the three different states. Portrait, landscape or * fullscreen+landscape. This has to be done programmatically because we handle the orientation * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources * do not get reloaded.//from w w w .j ava 2s .c o m */ private void layout() { boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE); listFragment.setLabelVisibility(isPortrait); closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE); if (isFullscreen) { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT); } else if (isPortrait) { setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT); setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM); } else { videoBox.setTranslationY(0); // Reset any translation that was applied in portrait. int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp); setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT); int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP); setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT); setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); } }
From source file:com.github.andrewlord1990.snackbarbuildersample.SampleActivity.java
private void setupData() { samples = new LinkedHashMap<>(); samples.put(MESSAGE, new OnClickListener() { @Override//w w w . ja v a2 s . c o m public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).build().show(); } }); samples.put(ACTION, new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION) .actionClickListener(getActionClickListener()).build().show(); } }); samples.put("Custom Text Colours Using Resources", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message("Message in different color").actionText(ACTION) .actionClickListener(getActionClickListener()).messageTextColorRes(R.color.red) .actionTextColorRes(R.color.green).build().show(); } }); samples.put("Custom Text Colours Using Colors", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message("Message in different color").actionText(ACTION) .actionClickListener(getActionClickListener()).messageTextColor(green).actionTextColor(red) .build().show(); } }); samples.put("Standard callback", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION) .callback(createCallback()).build().show(); } }); samples.put("SnackbarBuilder callback", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION) .snackbarCallback(createSnackbarCallback()).build().show(); } }); samples.put("Timeout callback", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION) .timeoutDismissCallback(new SnackbarTimeoutDismissCallback() { @Override public void onSnackbarTimedOut(Snackbar snackbar) { showToast("Timed out"); } }).build().show(); } }); samples.put("Lowercase action", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message(MESSAGE).actionText(ACTION).lowercaseAction() .build().show(); } }); samples.put("Custom timeout", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message("This has a custom timeout").duration(10000) .build().show(); } }); samples.put("Icon", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).icon(R.drawable.ic_android_24dp) .iconMarginStartRes(R.dimen.snackbar_icon_margin) .iconMarginEndRes(R.dimen.snackbar_icon_margin).message("This has an icon on it") .duration(Snackbar.LENGTH_LONG).build().show(); } }); samples.put("Multicolour", new OnClickListener() { @Override public void onClick(View view) { new SnackbarBuilder(SampleActivity.this).message("this").appendMessage(" message", Color.RED) .appendMessage(" has", Color.GREEN).appendMessage(" lots", Color.BLUE) .appendMessage(" of", Color.GRAY).appendMessage(" colors", Color.MAGENTA) .duration(Snackbar.LENGTH_LONG).build().show(); } }); samples.put("Using wrapper", new OnClickListener() { @Override public void onClick(View view) { SnackbarWrapper wrapper = new SnackbarBuilder(SampleActivity.this).message("Using wrapper") .duration(Snackbar.LENGTH_LONG).buildWrapper(); wrapper.appendMessage(" to add more text", Color.YELLOW).show(); } }); samples.put("Toast with red text", new OnClickListener() { @Override public void onClick(View view) { new ToastBuilder(SampleActivity.this).message("Custom toast").messageTextColor(Color.RED).build() .show(); } }); samples.put("Toast with custom position", new OnClickListener() { @Override public void onClick(View view) { new ToastBuilder(SampleActivity.this).message("Positioned toast").duration(Toast.LENGTH_LONG) .gravity(Gravity.TOP).gravityOffsetX(100).gravityOffsetY(300).build().show(); } }); }