Example usage for android.view Gravity START

List of usage examples for android.view Gravity START

Introduction

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

Prototype

int START

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

Click Source Link

Document

Push object to x-axis position at the start of its container, not changing its size.

Usage

From source file:org.mdc.chess.SeekBarPreference.java

@Override
protected View onCreateView(ViewGroup parent) {
    TextView name = new TextView(getContext());
    name.setText(getTitle());//from   w w  w.j  a va  2  s .  c  o  m
    //name.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
    TextViewCompat.setTextAppearance(name, android.R.style.TextAppearance_Large);
    name.setGravity(Gravity.START);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.START;
    lp.weight = 1.0f;
    name.setLayoutParams(lp);

    currValBox = new TextView(getContext());
    currValBox.setTextSize(12);
    currValBox.setTypeface(Typeface.MONOSPACE, Typeface.ITALIC);
    currValBox.setPadding(2, 5, 0, 0);
    currValBox.setText(valToString());
    lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER;
    currValBox.setLayoutParams(lp);

    LinearLayout row1 = new LinearLayout(getContext());
    row1.setOrientation(LinearLayout.HORIZONTAL);
    row1.addView(name);
    row1.addView(currValBox);

    final SeekBar bar = new SeekBar(getContext());
    bar.setMax(maxValue);
    bar.setProgress(currVal);
    bar.setOnSeekBarChangeListener(this);
    lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.END;
    bar.setLayoutParams(lp);

    CharSequence summaryCharSeq = getSummary();
    boolean haveSummary = (summaryCharSeq != null) && (summaryCharSeq.length() > 0);
    TextView summary = null;
    if (haveSummary) {
        summary = new TextView(getContext());
        summary.setText(getSummary());
        //            summary.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
        summary.setGravity(Gravity.START);
        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.gravity = Gravity.START;
        lp.weight = 1.0f;
        summary.setLayoutParams(lp);
    }

    LinearLayout layout = new LinearLayout(getContext());
    layout.setPadding(25, 5, 25, 5);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(row1);
    layout.addView(bar);
    if (summary != null) {
        layout.addView(summary);
    }
    layout.setId(android.R.id.widget_frame);

    currValBox.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            View content = View.inflate(SeekBarPreference.this.getContext(), R.layout.select_percentage, null);
            final AlertDialog.Builder builder = new AlertDialog.Builder(SeekBarPreference.this.getContext());
            builder.setView(content);
            String title = "";
            String key = getKey();
            if (key.equals("strength")) {
                title = getContext().getString(R.string.edit_strength);
            } else if (key.equals("bookRandom")) {
                title = getContext().getString(R.string.edit_randomization);
            }
            builder.setTitle(title);
            final EditText valueView = (EditText) content.findViewById(R.id.selpercentage_number);
            valueView.setText(currValBox.getText().toString().replaceAll("%", "").replaceAll(",", "."));
            final Runnable selectValue = new Runnable() {
                public void run() {
                    try {
                        String txt = valueView.getText().toString();
                        int value = (int) (Double.parseDouble(txt) * 10 + 0.5);
                        if (value < 0)
                            value = 0;
                        if (value > maxValue)
                            value = maxValue;
                        onProgressChanged(bar, value, false);
                    } catch (NumberFormatException ignored) {

                    }
                }
            };
            valueView.setOnKeyListener(new OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        selectValue.run();
                        return true;
                    }
                    return false;
                }
            });
            builder.setPositiveButton("Ok", new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    selectValue.run();
                }
            });
            builder.setNegativeButton("Cancel", null);

            builder.create().show();
        }
    });

    return layout;
}

From source file:com.smart.able2include.SimpleTextOverlayView.java

private void createView() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);/*from  w  w w.jav a 2s .  c  o m*/

    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;
    params.y = 30;
    params.width = wm.getDefaultDisplay().getWidth();
    params.height = wm.getDefaultDisplay().getHeight() - 30;

    frameLayout = new RelativeLayout(mServiceContext);
    LayoutInflater layoutInflater = (LayoutInflater) mServiceContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout);

    TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText);
    text.setText(mSimpleText);
    dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            RemoveOvelay();
            delegate.onClick();
        }
    });
    synchronized (mSyncToken) {
        wm.addView(frameLayout, params);
        mOnTop = true;
    }
}

From source file:jp.bugscontrol.ui.ActivityServer.java

@Override
public void onBackPressed() {
    if (drawerLayout.isDrawerVisible(Gravity.START)) {
        drawerLayout.closeDrawer(Gravity.START);
    } else {//from   w w w.  ja v  a2 s  . c  om
        super.onBackPressed();
    }
}

From source file:org.michaelbel.bottomsheet.BottomSheetCell.java

public BottomSheetCell setIcon(@DrawableRes int resId, @ColorInt int color) {
    if (resId != 0) {
        Drawable res = ContextCompat.getDrawable(getContext(), resId);
        res.clearColorFilter();//w  w w .j  av a2  s .c om
        res.mutate().setColorFilter(color, PorterDuff.Mode.MULTIPLY);

        iconView.setImageDrawable(res);

        FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params2.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
        params2.leftMargin = Utils.dp(getContext(), 72);
        params2.rightMargin = Utils.dp(getContext(), 16);

        textView.setLayoutParams(params2);
    } else {
        FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        params2.gravity = Gravity.START | Gravity.CENTER_VERTICAL;
        params2.leftMargin = Utils.dp(getContext(), 16);
        params2.rightMargin = Utils.dp(getContext(), 16);

        textView.setLayoutParams(params2);
    }

    return this;
}

From source file:com.bradbergeron.splitviewcontrollerdemo.activities.MainActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activty_main);

    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from   w w w . java2  s .c o  m

    final ActionBar actionBar = getSupportActionBar();

    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
    }

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {
        @Override
        public void onDrawerOpened(final View drawerView) {
            super.onDrawerOpened(drawerView);

            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(final View drawerView) {
            super.onDrawerClosed(drawerView);

            invalidateOptionsMenu();
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerFragment = (DrawerFragment) getFragmentManager().findFragmentById(R.id.drawer);
}

From source file:com.vmihalachi.turboeditor.activity.HomeActivity.java

/**
 * {@inheritDoc}//from   w w w  .j  a v  a2s. c o m
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    // setup the navigation drawer
    setupNavigationDrawer();
    // Replace fragment
    getFragmentManager().beginTransaction().replace(R.id.fragment_editor, new NoFileOpenedFragment()).commit();
    /* First Time we open this activity */
    if (savedInstanceState == null) {
        // Open
        mDrawerLayout.openDrawer(Gravity.START);
        // Set the default title
        getActionBar().setTitle(getString(R.string.nome_app_turbo_editor));
    }
    // parse the intent
    parseIntent(getIntent());
    // show a dialog with the changelog
    showChangeLog();
}

From source file:jp.bugscontrol.ui.ActivityServer.java

@Override
public void onServerSelected(final int position) {
    drawerLayout.closeDrawer(Gravity.START);
    if (position == Server.servers.size()) {
        openServerManager();/*  w w  w.j  ava  2  s.c  o  m*/
    } else {
        getSupportFragmentManager().popBackStack();
        getSupportFragmentManager().popBackStack();
        setServer(position);
    }
}

From source file:com.github.pennyfive.cinemafinlando.ui.activity.generic.DrawerActivity.java

public final void setActionBarTitle(String title) {
    actionBarTitle = title;/*w  ww .  jav a2s.  c o m*/
    if (drawer == null || !drawer.isDrawerOpen(Gravity.START)) {
        updateActionBarTitle(title);
    }
}

From source file:net.mm2d.dmsexplorer.ServerDetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.frg_server_detail, container, false);
    final String udn = getArguments().getString(Const.EXTRA_UDN);
    final DataHolder dataHolder = DataHolder.getInstance();
    final MediaServer server = dataHolder.getMsControlPoint().getMediaServer(udn);
    if (server == null) {
        getActivity().finish();/* ww  w .  j av a 2 s . co  m*/
        return rootView;
    }
    final TextView titleView = (TextView) rootView.findViewById(R.id.title);
    if (titleView != null) {
        titleView.setText(server.getFriendlyName());
        titleView.setBackgroundColor(ThemeUtils.getAccentColor(server.getFriendlyName()));
    }
    final RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.server_detail);
    final PropertyAdapter adapter = new PropertyAdapter(getContext());
    setupPropertyAdapter(adapter, server);
    adapter.setOnItemLinkClickListener(this);
    recyclerView.setAdapter(adapter);

    FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    if (fab == null) {
        fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    }
    if (fab != null) {
        fab.setOnClickListener(view -> {
            final Intent intent = CdsListActivity.makeIntent(getContext(), udn);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                final TransitionSet ts = new TransitionSet();
                ts.addTransition(new Slide(Gravity.START));
                ts.addTransition(new Fade());
                getActivity().getWindow().setExitTransition(ts);
                startActivity(intent,
                        ActivityOptions.makeSceneTransitionAnimation(getActivity(), view, "share").toBundle());
            } else {
                startActivity(intent);
            }
        });
    }
    return rootView;
}

From source file:com.z299studio.pb.Snackbar.java

@Override
public void onStart() {
    super.onStart();
    if (getDialog() != null) {
        Window window = getDialog().getWindow();
        window.setWindowAnimations(R.style.SnackbarAnimation);
        Resources res = getResources();
        int height = (int) (res.getDimension(R.dimen.snackbar_height_single) + 0.5f);
        boolean leftAlign = res.getBoolean(R.bool.snackbar_left_align);
        WindowManager.LayoutParams lp = window.getAttributes();
        lp.gravity = Gravity.BOTTOM | Gravity.START;
        lp.x = 0;/*from   w  ww  .ja  v  a 2s  .  c  o m*/
        lp.y = 0;
        lp.height = height;
        if (!leftAlign) {
            Point windowSize = new Point();
            ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
                    .getSize(windowSize);
            lp.width = windowSize.x;
        } else {
            lp.height += (int) (res.getDimension(R.dimen.snackbar_horizontal_margin) + 0.5f);
        }
        window.setAttributes(lp);
    }
}