Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

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

Prototype

int LEFT

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

Click Source Link

Document

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

Usage

From source file:com.flowzr.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activity = this;
    setContentView(R.layout.main);/* w  w w  .  ja va2 s  .  c o m*/

    actionBar = getSupportActionBar();

    //@see: http://stackoverflow.com/questions/16539251/get-rid-of-blue-line, 
    //only way found to remove on various devices 2.3x, 3.0, ...
    actionBar.setBackgroundDrawable(new ColorDrawable(R.color.f_dark));

    setupDrawer();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // create new tabs and and set up the titles of the tabs
    mAccountTab = setupAccountsTab(actionBar);
    mBlotterTab = setupBlotterTab(actionBar);
    mBudgetsTab = setupBudgetsTab(actionBar);

    Intent intent = getIntent();

    mAdapter = new MyAdapter(getSupportFragmentManager(), intent);
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
    viewPager.setAdapter(mAdapter);
    viewPager.setOnPageChangeListener(this);

    mAccountTab.setTabListener(this);
    mBlotterTab.setTabListener(this);
    mBudgetsTab.setTabListener(this);

    addMyTabs();

    if (intent.hasExtra(REQUEST_BLOTTER)) {
        blotterFragment = new BlotterFragment();
        if (intent.hasExtra(EntityListActivity.REQUEST_NEW_TRANSACTION_FROM_TEMPLATE)) {
            Bundle bundle = new Bundle();
            bundle.putInt(BlotterFragment.EXTRA_REQUEST_TYPE,
                    BlotterFragment.NEW_TRANSACTION_FROM_TEMPLATE_REQUEST);
            blotterFragment.setArguments(bundle);
        }
        loadTabFragment(blotterFragment, R.layout.blotter, intent.getExtras(), TAB_BLOTTER);

    } else if (intent.hasExtra(REQUEST_SPLIT_BLOTTER)) {
        loadTabFragment(new SplitsBlotterActivity(), R.layout.blotter, intent.getExtras(), TAB_BLOTTER);
    } else if (intent.hasExtra(REQUEST_BUDGET_BLOTTER)) {
        loadTabFragment(new BudgetBlotterFragment(), R.layout.blotter, intent.getExtras(), TAB_BLOTTER);
    } else {
        StartupScreen startupScreen = MyPreferences.getStartupScreen(this);
        viewPager.setCurrentItem(startupScreen.ordinal());
    }

    if (WebViewDialog.checkVersionAndShowWhatsNewIfNeeded(this)) {
        if (mDrawerLayout != null) {
            mDrawerLayout.openDrawer(Gravity.LEFT);
        }
    }

    initialLoad();

    FlowzrSyncEngine.setUpdatable(this);
}

From source file:at.andreasrohner.spartantimelapserec.BackgroundService.java

@SuppressWarnings("deprecation")
@Override/*from   w w w .j  a va  2s.c  om*/
public void onCreate() {
    created = true;

    settings = new RecSettings();
    settings.load(getApplicationContext(),
            PreferenceManager.getDefaultSharedPreferences(getApplicationContext()));

    createNotification(NOTIFICATION_ID);

    if (settings.isSchedRecEnabled() && settings.getSchedRecTime() > System.currentTimeMillis() + 10000) {
        AlarmManager alarmMgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(getApplicationContext(), ScheduleReceiver.class);
        PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);

        alarmMgr.set(AlarmManager.RTC_WAKEUP, settings.getSchedRecTime(), alarmIntent);

        stopSelf();
        return;
    }

    // Create new SurfaceView, set its size to 1x1, move
    // it to the top left corner and set this service as a callback
    WindowManager winMgr = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    surfaceView = new SurfaceView(this);
    // deprecated setting, but required on Android versions prior to 3.0
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
        surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    surfaceView.getHolder().addCallback(this);

    LayoutParams layoutParams = new WindowManager.LayoutParams(1, 1,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
    layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
    winMgr.addView(surfaceView, layoutParams);

    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
    wakeLock.setReferenceCounted(false);
    wakeLock.acquire();
}

From source file:com.flowzr.budget.holo.activity.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    if (PinProtection.isUnlocked()) {
        if (WebViewDialog.checkVersionAndShowWhatsNewIfNeeded(this)) {
            if (mDrawerLayout != null) {
                mDrawerLayout.openDrawer(Gravity.LEFT);
            }/*  w  w  w .  ja va2  s.  c  o m*/
        }
    }
}

From source file:co.lemonlabs.mortar.example.core.util.ScreenConductor.java

public void showDrawer(S screen) {
    View oldChild = getDrawerView();

    if (destroyOldScope(screen, oldChild)) {
        View newChild = createNewChildView(screen, drawerViewId);

        if (oldChild != null) {
            container.removeView(oldChild);
        }//from w w  w .j  a v  a  2  s. c  om

        // Set some basic layout parameters so the drawer works
        DrawerLayout.LayoutParams params = new DrawerLayout.LayoutParams(
                context.getResources().getDimensionPixelSize(R.dimen.navigation_drawer_width),
                ViewGroup.LayoutParams.MATCH_PARENT);
        params.gravity = Gravity.LEFT;
        newChild.setLayoutParams(params);

        container.addView(newChild, 1);
    }
}

From source file:com.architjn.materialicons.ui.fragments.HomeFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == android.R.id.home) {
        drawer.openDrawer(Gravity.LEFT);
    }/*  w  ww.  ja v  a2 s .c o  m*/
    if (id == R.id.action_sendemail) {
        StringBuilder emailBuilder = new StringBuilder();

        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("mailto:" + getResources().getString(R.string.email_id)));
        intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject));

        emailBuilder.append("\n \n \nOS Version: ").append(System.getProperty("os.version")).append("(")
                .append(Build.VERSION.INCREMENTAL).append(")");
        emailBuilder.append("\nOS API Level: ").append(Build.VERSION.SDK_INT);
        emailBuilder.append("\nDevice: ").append(Build.DEVICE);
        emailBuilder.append("\nManufacturer: ").append(Build.MANUFACTURER);
        emailBuilder.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT)
                .append(")");
        PackageInfo appInfo = null;
        try {
            appInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        assert appInfo != null;
        emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName);
        emailBuilder.append("\nApp Version Code: ").append(appInfo.versionCode);

        intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString());
        startActivity(Intent.createChooser(intent, (getResources().getString(R.string.send_title))));
        return true;
    } else if (id == R.id.action_share) {
        Intent sharingIntent = new Intent(Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = getResources().getString(R.string.share_one)
                + getResources().getString(R.string.developer_name)
                + getResources().getString(R.string.share_two) + MARKET_URL + getActivity().getPackageName();
        sharingIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, (getResources().getString(R.string.share_title))));
    } else if (id == R.id.action_changelog) {
        showChangelog();
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.gcssloop.diycode.activity.UserActivity.java

private void initScrollAnimation(ViewHolder holder) {
    NestedScrollView scrollView = holder.get(R.id.scroll_view);
    ImageView avatar = holder.get(R.id.avatar);
    TextView username = holder.get(R.id.username);
    View backbground = holder.get(R.id.background);

    this.expectAnimMove = new ExpectAnim().expect(avatar)
            .toBe(topOfParent().withMarginDp(13), leftOfParent().withMarginDp(13), scale(0.5f, 0.5f))
            .expect(username)//from  w w w . ja v  a 2s .  c  o m
            .toBe(toRightOf(avatar).withMarginDp(16), sameCenterVerticalAs(avatar), alpha(0.5f))
            .expect(backbground)
            .toBe(height(DensityUtils.dip2px(this, 60)).withGravity(Gravity.LEFT, Gravity.TOP)).toAnimation();

    scrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
        @Override
        public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX,
                int oldScrollY) {
            final float percent = (scrollY * 1f) / v.getMaxScrollAmount();
            expectAnimMove.setPercent(percent);
        }
    });
}

From source file:android.support.transition.SidePropagation.java

private int getMaxDistance(ViewGroup sceneRoot) {
    switch (mSide) {
    case Gravity.LEFT:
    case Gravity.RIGHT:
    case Gravity.START:
    case Gravity.END:
        return sceneRoot.getWidth();
    default:/*from  w ww . j  ava 2 s. co m*/
        return sceneRoot.getHeight();
    }
}

From source file:com.gh4a.BaseActivity.java

protected boolean closeDrawers() {
    boolean result = false;
    if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
        mDrawerLayout.closeDrawer(Gravity.LEFT);
        result = true;// w w w  .  j a  va  2 s  .  c  om
    }
    if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
        mDrawerLayout.closeDrawer(Gravity.RIGHT);
        result = true;
    }
    return result;
}

From source file:at.alladin.rmbt.android.map.overlay.RMBTBalloonOverlayView.java

public void setBalloonData(final RMBTBalloonOverlayItem item, final ViewGroup parent) {
    // map our custom item data to fields
    //        title.setText(item.getTitle());
    resultItems = item.getResultItems();

    resultListView.removeAllViews();/*from   www . ja v  a2  s .co m*/

    final float scale = getResources().getDisplayMetrics().density;

    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    final int topBottomItem = Helperfunctions.dpToPx(3, scale);

    final int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    final int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    final int topBottomImg = Helperfunctions.dpToPx(1, scale);

    if (resultItems != null && resultItems.length() > 0) {

        for (int i = 0; i < 1; i++)
            // JSONObject resultListItem;
            try {
                final JSONObject result = resultItems.getJSONObject(i);

                final LayoutInflater resultInflater = (LayoutInflater) context
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                final View resultView = resultInflater.inflate(R.layout.balloon_overlay_listitem, parent);

                final LinearLayout measurementLayout = (LinearLayout) resultView
                        .findViewById(R.id.resultMeasurementList);
                measurementLayout.setVisibility(View.GONE);

                final LinearLayout netLayout = (LinearLayout) resultView.findViewById(R.id.resultNetList);
                netLayout.setVisibility(View.GONE);

                final TextView measurementHeader = (TextView) resultView.findViewById(R.id.resultMeasurement);
                measurementHeader.setVisibility(View.GONE);

                final TextView netHeader = (TextView) resultView.findViewById(R.id.resultNet);
                netHeader.setVisibility(View.GONE);

                final TextView dateHeader = (TextView) resultView.findViewById(R.id.resultDate);
                dateHeader.setVisibility(View.GONE);

                dateHeader.setText(result.optString("time_string"));

                final JSONArray measurementArray = result.getJSONArray("measurement");

                final JSONArray netArray = result.getJSONArray("net");

                for (int j = 0; j < measurementArray.length(); j++) {

                    final JSONObject singleItem = measurementArray.getJSONObject(j);

                    final LinearLayout measurememtItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

                    measurememtItemLayout.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));

                    measurememtItemLayout.setGravity(Gravity.CENTER_VERTICAL);
                    measurememtItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem,
                            topBottomItem);

                    final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle);
                    itemTitle.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f));
                    itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle);
                    itemTitle.setWidth(0);
                    itemTitle.setGravity(Gravity.LEFT);
                    itemTitle.setText(singleItem.getString("title"));

                    measurememtItemLayout.addView(itemTitle);

                    final ImageView itemClassification = new ImageView(context);
                    itemClassification.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f));
                    itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);
                    // itemClassification.set setGravity(Gravity.LEFT);

                    itemClassification.setImageDrawable(getResources().getDrawable(
                            Helperfunctions.getClassificationImage(singleItem.getInt("classification"))));

                    measurememtItemLayout.addView(itemClassification);

                    final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue);
                    itemValue.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f));
                    itemValue.setTextAppearance(context, R.style.balloonResultItemValue);
                    itemValue.setWidth(0);
                    itemValue.setGravity(Gravity.LEFT);
                    itemValue.setText(singleItem.getString("value"));

                    measurememtItemLayout.addView(itemValue);

                    measurementLayout.addView(measurememtItemLayout);

                    final View divider = new View(context);
                    divider.setLayoutParams(new LinearLayout.LayoutParams(
                            android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1));
                    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

                    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

                    measurementLayout.addView(divider);

                    measurementLayout.invalidate();
                }

                for (int j = 0; j < netArray.length(); j++) {

                    final JSONObject singleItem = netArray.getJSONObject(j);

                    final LinearLayout netItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

                    netItemLayout.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
                    netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem);

                    netItemLayout.setGravity(Gravity.CENTER_VERTICAL);

                    final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle);
                    itemTitle.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f));
                    itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle);
                    itemTitle.setWidth(0);
                    itemTitle.setGravity(Gravity.LEFT);
                    itemTitle.setText(singleItem.getString("title"));

                    netItemLayout.addView(itemTitle);

                    final ImageView itemClassification = new ImageView(context);
                    itemClassification.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f));
                    itemClassification.setPadding(0, topBottomImg, 0, topBottomImg);

                    itemClassification.setImageDrawable(
                            context.getResources().getDrawable(R.drawable.traffic_lights_none));
                    netItemLayout.addView(itemClassification);

                    final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue);
                    itemValue.setLayoutParams(
                            new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f));
                    itemValue.setTextAppearance(context, R.style.balloonResultItemValue);
                    itemValue.setWidth(0);
                    itemValue.setGravity(Gravity.LEFT);
                    itemValue.setText(singleItem.optString("value", null));

                    netItemLayout.addView(itemValue);

                    netLayout.addView(netItemLayout);

                    final View divider = new View(context);
                    divider.setLayoutParams(new LinearLayout.LayoutParams(
                            android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1));
                    divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv);

                    divider.setBackgroundResource(R.drawable.bg_trans_light_10);

                    netLayout.addView(divider);

                    netLayout.invalidate();
                }

                measurementHeader.setVisibility(View.VISIBLE);
                netHeader.setVisibility(View.VISIBLE);

                measurementLayout.setVisibility(View.VISIBLE);
                netLayout.setVisibility(View.VISIBLE);

                dateHeader.setVisibility(View.VISIBLE);

                resultListView.addView(resultView);

                Log.d(DEBUG_TAG, "View Added");
                // codeText.setText(resultListItem.getString("sync_code"));

            } catch (final JSONException e) {
                e.printStackTrace();
            }

        progessBar.setVisibility(View.GONE);
        emptyView.setVisibility(View.GONE);

        resultListView.setVisibility(View.VISIBLE);

        resultListView.invalidate();
    } else {
        Log.i(DEBUG_TAG, "LEERE LISTE");
        progessBar.setVisibility(View.GONE);
        emptyView.setVisibility(View.VISIBLE);
        emptyView.setText(context.getString(R.string.error_no_data));
        emptyView.invalidate();
    }
}

From source file:com.arksh.summer.ui.zone.widget.ExpandableTextView.java

/**
 * ?/* w  ww  .jav  a2  s .  c  o m*/
 * @param attrs
 */
private void init(AttributeSet attrs) {
    mCollapsedStatus = new SparseBooleanArray();

    TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.ExpandableTextView);
    mMaxCollapsedLines = typedArray.getInt(R.styleable.ExpandableTextView_maxCollapsedLines,
            MAX_COLLAPSED_LINES);
    mAnimationDuration = typedArray.getInt(R.styleable.ExpandableTextView_animDuration, DEFAULT_ANIM_DURATION);
    mExpandDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_expandDrawable);
    mCollapseDrawable = typedArray.getDrawable(R.styleable.ExpandableTextView_collapseDrawable);

    textCollapse = typedArray.getString(R.styleable.ExpandableTextView_textCollapse);
    textExpand = typedArray.getString(R.styleable.ExpandableTextView_textExpand);
    showExpandCollapseDrawable = typedArray
            .getBoolean(R.styleable.ExpandableTextView_showExpandCollapseDrawable, true);

    if (showExpandCollapseDrawable) {
        if (mExpandDrawable == null) {
            mExpandDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_down);
        }
        if (mCollapseDrawable == null) {
            mCollapseDrawable = ContextCompat.getDrawable(getContext(), R.drawable.icon_green_arrow_up);
        }
    }

    if (TextUtils.isEmpty(textCollapse)) {
        textCollapse = getContext().getString(R.string.shink);
    }
    if (TextUtils.isEmpty(textExpand)) {
        textExpand = getContext().getString(R.string.expand);
    }
    contentTextColor = typedArray.getColor(R.styleable.ExpandableTextView_contentTextColor,
            ContextCompat.getColor(getContext(), R.color.light_gray));
    contentTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_contentTextSize,
            DisplayUtil.sp2px(14));

    collapseExpandTextColor = typedArray.getColor(R.styleable.ExpandableTextView_collapseExpandTextColor,
            ContextCompat.getColor(getContext(), R.color.main_color));
    collapseExpandTextSize = typedArray.getDimension(R.styleable.ExpandableTextView_collapseExpandTextSize,
            DisplayUtil.sp2px(14));

    grarity = typedArray.getInt(R.styleable.ExpandableTextView_collapseExpandGrarity, Gravity.LEFT);

    typedArray.recycle();
    // enforces vertical orientation
    setOrientation(LinearLayout.VERTICAL);
    // default visibility is gone
    setVisibility(GONE);
}