Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

In this page you can find the example usage for android.view Gravity BOTTOM.

Prototype

int BOTTOM

To view the source code for android.view Gravity BOTTOM.

Click Source Link

Document

Push object to the bottom of its container, not changing its size.

Usage

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. j av  a  2 s.  co  m*/
    return rootView;
}

From source file:com.example.apptankcontroller.common.logger.LogFragment.java

public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setBackgroundColor(Color.WHITE);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);// www  .  j a  va 2 s .  c o m
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    return mScrollView;
}

From source file:com.common.library.logger.LogFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);//from ww w.  j  a v  a 2s .  c  o m
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);
    Log.setLogNode(mLogView);
    return mScrollView;
}

From source file:am.project.x.business.drawables.combinationdrawable.CombinationDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override// ww w  .  j a va  2s .c o m
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
    default:
    case 0:
        drawable.setGravity(Gravity.CENTER);
        break;
    case 1:
        drawable.setGravity(Gravity.LEFT);
        break;
    case 2:
        drawable.setGravity(Gravity.CENTER_HORIZONTAL);
        break;
    case 3:
        drawable.setGravity(Gravity.RIGHT);
        break;
    case 4:
        drawable.setGravity(Gravity.CENTER_VERTICAL);
        break;
    case 5:
        drawable.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
        break;
    case 6:
        drawable.setGravity(Gravity.BOTTOM);
        break;
    case 7:
        drawable.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
        break;
    case 8:
        drawable.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
        break;
    }
}

From source file:com.simplytapp.demo.common.logger.LogFragment.java

public View inflateViews() {
    mScrollView = new ScrollView(getActivity());
    ViewGroup.LayoutParams scrollParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mScrollView.setLayoutParams(scrollParams);

    mLogView = new LogView(getActivity());
    ViewGroup.LayoutParams logParams = new ViewGroup.LayoutParams(scrollParams);
    logParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLogView.setLayoutParams(logParams);
    mLogView.setClickable(true);//from   w w  w . ja va2s . c  o  m
    mLogView.setFocusable(true);
    mLogView.setTypeface(Typeface.MONOSPACE);

    // Want to set padding as 16 dips, setPadding takes pixels.  Hooray math!
    int paddingDips = 16;
    double scale = getResources().getDisplayMetrics().density;
    int paddingPixels = (int) ((paddingDips * (scale)) + .5);
    mLogView.setPadding(paddingPixels, paddingPixels, paddingPixels, paddingPixels);
    mLogView.setCompoundDrawablePadding(paddingPixels);

    mLogView.setGravity(Gravity.BOTTOM);
    mLogView.setTextAppearance(getActivity(), android.R.style.TextAppearance_Holo_Medium);

    mScrollView.addView(mLogView);

    return mScrollView;
}

From source file:com.bt.download.android.gui.util.UIUtils.java

public static void showToastMessage(Context context, String message, int duration) {
    showToastMessage(context, message, duration, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0);
}

From source file:com.endiansoftware.echo.remotewatch.GcmBroadcastReceiver.java

@Override
public void onReceive(Context context, Intent intent) {

    /*/* w  w w.j a v a2s .c o  m*/
       // Explicitly specify that GcmIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(),
        GcmIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));
    setResultCode(Activity.RESULT_OK);
    */

    /*
    // ?    ?? .
    Intent popupIntent = new Intent(context, Popup.class)
        .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    //  .
    context.startActivity(popupIntent);
            
    */

    LinearLayout layout = new LinearLayout(context);
    //layout.setBackgroundResource(R.color.LightOrange);

    TextView tv = new TextView(context);
    // set the TextView properties like color, size etc
    tv.setTextColor(Color.RED);
    tv.setTextSize(15);

    tv.setGravity(Gravity.CENTER_VERTICAL);

    // set the text you want to show in  Toast
    tv.setText("My Custom Toast at Bottom of Screen");

    layout.addView(tv);

    Toast toast = new Toast(context); //context is object of Context write "this" if you are an Activity
    // Set The layout as Toast View
    toast.setView(layout);

    // Position you toast here toast position is 50 dp from bottom you can give any integral value
    toast.setGravity(Gravity.BOTTOM, 0, 50);
    toast.show();
}

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;
    }//  w w w . 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: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 va  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.jauker.badgeview.example.ViewsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.fragment_views, null);

    View backgroundDefaultView = layout.findViewById(R.id.backgroundDefault);
    backgroundDefaultBadge = new BadgeView(getActivity());
    backgroundDefaultBadge.setBadgeCount(42);
    backgroundDefaultBadge.setTargetView(backgroundDefaultView);

    View backgroundDrawableView = layout.findViewById(R.id.backgroundDrawable);
    backgroundDrawableBadge = new BadgeView(getActivity());
    backgroundDrawableBadge.setBadgeCount(88);
    backgroundDrawableBadge.setBackgroundResource(R.drawable.badge_blue);
    backgroundDrawableBadge.setTargetView(backgroundDrawableView);

    View backgroundShapeView = layout.findViewById(R.id.backgroundShape);
    backgroundShapeBadge = new BadgeView(getActivity());
    backgroundShapeBadge.setBadgeCount(47);
    backgroundShapeBadge.setBackground(12, Color.parseColor("#9b2eef"));
    backgroundShapeBadge.setTargetView(backgroundShapeView);

    View counterView = layout.findViewById(R.id.counter);
    counterView.setOnClickListener(this);
    counterBadge = new BadgeView(getActivity());
    counterBadge.setBadgeCount(-2);/* w w  w.  j  a  va 2  s . c o m*/
    counterBadge.setTargetView(counterView);

    View gravityView = layout.findViewById(R.id.gravity);
    gravityView.setOnClickListener(this);
    gravityBadge = new BadgeView(getActivity());
    gravityBadge.setBadgeGravity(Gravity.LEFT | Gravity.BOTTOM);
    gravityBadge.setBadgeCount(4);
    gravityBadge.setTargetView(gravityView);

    View textStyleView = layout.findViewById(R.id.textStyle);
    textStyleView.setOnClickListener(this);
    textStyleBadge = new BadgeView(getActivity());
    textStyleBadge.setBadgeCount(18);
    textStyleBadge.setTargetView(textStyleView);
    textStyleBadge.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
    textStyleBadge.setShadowLayer(2, -1, -1, Color.GREEN);

    View visibilityView = layout.findViewById(R.id.visibility);
    visibilityView.setOnClickListener(this);
    visibilityBadgeView = new BadgeView(getActivity());
    visibilityBadgeView.setBadgeCount(1);
    visibilityBadgeView.setTargetView(visibilityView);

    return layout;
}