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:autobahn.demo.com.autobahndemo.EchoClientActivity.java
private void alert(String message) { Toast toast = Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0); toast.show();/*w w w . j av a 2 s . com*/ }
From source file:com.heyzap.cordova.ads.CDVBannerAd.java
public void show(final JSONArray args, final CallbackContext callbackContext) { String jsonPosition = args.optString(0, POSITION_BOTTOM); BannerOptions options = getOptions(args.optJSONObject(1)); String tag = args.optString(2); int position = Gravity.TOP; if (jsonPosition.equals(POSITION_BOTTOM)) { position = Gravity.BOTTOM;//from www. j a v a 2 s.c o m } BannerAdView currentBannerAdView = BannerAd.getCurrentBannerAdView(); if (currentBannerAdView != null && currentBannerAdView.getParent() != null) { callbackContext.success("A banner is already showing"); } else { BannerAd.display(cordova.getActivity(), position, tag, options); callbackContext.success(); } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.LocationObj.java
@Override public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) { JSONObject content = obj.getJson();/*from ww w .java 2s .c o m*/ TextView valueTV = new TextView(context); NumberFormat df = DecimalFormat.getNumberInstance(); df.setMaximumFractionDigits(5); df.setMinimumFractionDigits(5); String msg = "I'm at " + df.format(content.optDouble(COORD_LAT)) + ", " + df.format(content.optDouble(COORD_LONG)); valueTV.setText(msg); valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); valueTV.setGravity(Gravity.TOP | Gravity.LEFT); frame.addView(valueTV); }
From source file:com.github.shareme.gwscleanstatusbar.CleanStatusBarService.java
private WindowManager.LayoutParams getWindowManagerParams() { WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, PixelFormat.TRANSLUCENT); // must be translucent to support KitKat gradient params.gravity = Gravity.TOP; params.height = mStatusBarConfig.getStatusBarHeight(); return params; }
From source file:com.google.unity.AdMobPlugin.java
/** * Creates an {@link AdView} to old ads. * * @param activity The activity to place the {@code AdView}. * @param publisherId Your publisher ID from the AdMob or DFP console * @param adSizeString A string ad size constant representing the desired ad size. * @param positionAtTop True to position the ad at the top of the screen. False to position * the ad at the bottom of the screen. *///from w w w.j a v a 2s . c o m public static void createBannerView(final Activity activity, final String publisherId, final String adSizeString, final boolean positionAtTop) { Log.d(LOGTAG, "called createBannerView in Java code"); final AdMobPlugin plugin = AdMobPlugin.instance(); plugin.activity = activity; activity.runOnUiThread(new Runnable() { @Override public void run() { AdSize adSize = AdMobPlugin.adSizeFromSize(adSizeString); if (adSize == null) { Log.e(AdMobPlugin.LOGTAG, "AdSize is null. Did you use an AdSize constant?"); return; } plugin.adView = new AdView(activity, adSize, publisherId); plugin.adView.setAdListener(plugin); LinearLayout layout = new LinearLayout(activity); FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); layoutParams.gravity = positionAtTop ? Gravity.TOP : Gravity.BOTTOM; activity.addContentView(layout, layoutParams); LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT); layout.addView(plugin.adView, adParams); } }); }
From source file:com.google.android.apps.muzei.MainFragment.java
@Override public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) { // Set up the action bar final View actionBarContainer = view.findViewById(R.id.action_bar_container); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { actionBarContainer.setBackground(ScrimUtil.makeCubicGradientScrimDrawable(0x44000000, 8, Gravity.TOP)); }//from w w w .j a va2s .com final Toolbar toolbar = view.findViewById(R.id.toolbar); AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { activity.setSupportActionBar(toolbar); activity.getSupportActionBar().setDisplayShowTitleEnabled(false); } // Set up the container for the child fragments final View container = view.findViewById(R.id.container); if (savedInstanceState == null) { FirebaseAnalytics.getInstance(getActivity()).setCurrentScreen(getActivity(), "ArtDetail", ArtDetailFragment.class.getSimpleName()); getChildFragmentManager().beginTransaction().replace(R.id.container, new ArtDetailFragment()).commit(); } // Set up the bottom nav final BottomNavigationView bottomNavigationView = view.findViewById(R.id.bottom_nav); bottomNavigationView .setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull final MenuItem item) { if (getChildFragmentManager().isStateSaved()) { // Can't navigate after the state is saved return false; } switch (item.getItemId()) { case R.id.main_art_details: FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(), "ArtDetail", ArtDetailFragment.class.getSimpleName()); getChildFragmentManager().beginTransaction() .replace(R.id.container, new ArtDetailFragment()) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit(); return true; case R.id.main_choose_source: FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(), "ChooseSource", ChooseSourceFragment.class.getSimpleName()); getChildFragmentManager().popBackStack("main", FragmentManager.POP_BACK_STACK_INCLUSIVE); getChildFragmentManager().beginTransaction() .replace(R.id.container, new ChooseSourceFragment()).addToBackStack("main") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit(); return true; case R.id.main_effects: FirebaseAnalytics.getInstance(getContext()).setCurrentScreen(getActivity(), "Effects", EffectsFragment.class.getSimpleName()); getChildFragmentManager().popBackStack("main", FragmentManager.POP_BACK_STACK_INCLUSIVE); getChildFragmentManager().beginTransaction() .replace(R.id.container, new EffectsFragment()).addToBackStack("main") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).commit(); return true; default: return false; } } }); bottomNavigationView.setOnNavigationItemReselectedListener( new BottomNavigationView.OnNavigationItemReselectedListener() { @Override public void onNavigationItemReselected(@NonNull final MenuItem item) { if (item.getItemId() == R.id.main_art_details) { getActivity().getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); } } }); // Send the correct window insets to each view ViewCompat.setOnApplyWindowInsetsListener(view, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { // Ensure the action bar container gets the appropriate insets ViewCompat.dispatchApplyWindowInsets(actionBarContainer, insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(), insets.getSystemWindowInsetRight(), 0)); ViewCompat.dispatchApplyWindowInsets(container, insets.replaceSystemWindowInsets( insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), 0)); ViewCompat.dispatchApplyWindowInsets(bottomNavigationView, insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft(), 0, insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom())); return insets; } }); // Listen for visibility changes to know when to hide our views view.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int vis) { final boolean visible = (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) == 0; actionBarContainer.setVisibility(View.VISIBLE); actionBarContainer.animate().alpha(visible ? 1f : 0f).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { actionBarContainer.setVisibility(View.GONE); } } }); bottomNavigationView.setVisibility(View.VISIBLE); bottomNavigationView.animate().alpha(visible ? 1f : 0f).setDuration(200) .withEndAction(new Runnable() { @Override public void run() { if (!visible) { bottomNavigationView.setVisibility(View.GONE); } } }); } }); }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * toolBar * @return */ protected RelativeLayout buildToolbarLayout() { return createToolbarLayout(Gravity.LEFT, Gravity.TOP); }
From source file:cm.aptoide.pt.webservices.login.CreateUser.java
public void signUp(View v) { username = username_box.getText().toString(); password = password_box.getText().toString(); if (username.trim().length() > 0 && password.trim().length() > 0) { new CreateUserTask().execute(username.trim(), password.trim()); } else {//from w ww . ja va 2s . c om Toast toast = Toast.makeText(context, context.getString(R.string.check_your_credentials), Toast.LENGTH_SHORT); toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 30); toast.show(); } }
From source file:ac.robinson.bettertogether.QRPopupWindow.java
void showPopUp() { // could use mPopupWindow.getMaxAvailableHeight() if only there was a width version! DisplayMetrics displayMetrics = new DisplayMetrics(); mWindowManager.getDefaultDisplay().getMetrics(displayMetrics); int popupSize = (int) Math .round((displayMetrics.widthPixels > displayMetrics.heightPixels ? displayMetrics.heightPixels : displayMetrics.widthPixels) * 0.9); // normally: WindowManager.LayoutParams.WRAP_CONTENT); mPopupWindow.setWidth(popupSize);/*www . jav a 2 s. co m*/ mPopupWindow.setHeight(popupSize); mPopupWindow.setTouchable(true); mPopupWindow.setFocusable(true); mPopupWindow.setOutsideTouchable(true); mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog); int elevation = mAnchorView.getContext().getResources().getDimensionPixelSize(R.dimen.default_elevation); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mPopupWindow.setElevation(elevation); } // display as popup overlaying anchor view - as 4dp elevation is same as horizontal offset, use that precalculated value PopupWindowCompat.setOverlapAnchor(mPopupWindow, true); PopupWindowCompat.showAsDropDown(mPopupWindow, mAnchorView, -elevation, 0, Gravity.TOP | Gravity.END); }
From source file:com.google.android.apps.dashclock.configuration.ConfigureAppearanceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_configure_appearance, container, false); mCurrentStyleNames.put(AppearanceConfig.PREF_STYLE_TIME, sp.getString(AppearanceConfig.PREF_STYLE_TIME, AppearanceConfig.TIME_STYLE_NAMES[0])); configureStylePager((ViewPager) rootView.findViewById(R.id.pager_time_style), (PagerPositionStrip) rootView.findViewById(R.id.pager_time_position_strip), AppearanceConfig.TIME_STYLE_NAMES, AppearanceConfig.COMPONENT_TIME, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, AppearanceConfig.PREF_STYLE_TIME); mCurrentStyleNames.put(AppearanceConfig.PREF_STYLE_DATE, sp.getString(AppearanceConfig.PREF_STYLE_DATE, AppearanceConfig.DATE_STYLE_NAMES[0])); configureStylePager((ViewPager) rootView.findViewById(R.id.pager_date_style), (PagerPositionStrip) rootView.findViewById(R.id.pager_date_position_strip), AppearanceConfig.DATE_STYLE_NAMES, AppearanceConfig.COMPONENT_DATE, Gravity.CENTER_HORIZONTAL | Gravity.TOP, AppearanceConfig.PREF_STYLE_DATE); ((ConfigurationActivity) getActivity()).showWallpaper(); mAppearanceContainerView = rootView.findViewById(R.id.appearance_container); if (savedInstanceState == null) { getChildFragmentManager().beginTransaction() .add(R.id.appearance_more_container, new ConfigureAppearanceMoreFragment()).commit(); }//from ww w .ja v a2s .c om return rootView; }