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.example.android.navigationdrawerexample.BottomDrawerActivity.java

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

    setContentView(R.layout.activity_bottom_drawer);

    mTitle = mDrawerTitle = getTitle();//w ww  . j av  a2 s  .  co  m
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mVerticalDrawerLayout = (VerticalDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.bottom_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mVerticalDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mVerticalDrawerToggle = new ActionBarVerticalDrawerToggle(this, /* host Activity */
            getSupportActionBar(), /* ActionBar of the hosting Activity */
            mVerticalDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mVerticalDrawerToggle.setGravity(Gravity.BOTTOM);
    mVerticalDrawerLayout.setDrawerListener(mVerticalDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
}

From source file:com.example.android.navigationdrawerexample.ContentDrawerActivity.java

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

    setContentView(R.layout.activity_content_drawer);

    mTitle = mDrawerTitle = getTitle();/*  w ww . ja  v a  2s  .  c o m*/
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mContentDrawerLayout = (ContentDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.content_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mContentDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mContentDrawerToggle = new ActionBarContentDrawerToggle(this, /* host Activity */
            getSupportActionBar(), /* ActionBar of the hosting Activity */
            mContentDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mContentDrawerToggle.setGravity(Gravity.RIGHT);
    mContentDrawerLayout.setDrawerListener(mContentDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PhoneStateObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from  ww w . j  a v  a2 s. co  m*/
    TextView valueTV = new TextView(context);
    valueTV.setText(asText(content));
    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.orange.ocara.ui.activity.EditCommentActivity.java

@Override
void setUpToolbar() {
    super.setUpToolbar();

    final View responseButtonBar = LayoutInflater.from(this)
            .inflate(com.orange.ocara.R.layout.audit_object_toolbar, null);
    responseButtonBar.findViewById(com.orange.ocara.R.id.response_ok_button).setVisibility(View.GONE);

    responseButtonBar.findViewById(com.orange.ocara.R.id.response_nok_button).setVisibility(View.GONE);

    Toolbar.LayoutParams lp = new Toolbar.LayoutParams(Gravity.LEFT);
    responseButtonBar.setLayoutParams(lp);

    toolbar.addView(responseButtonBar);//from  w w w .  j av  a 2  s. c  o  m
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from w  w w. ja  va 2  s .  c o  m*/
    TextView valueTV = new TextView(context);
    valueTV.setText(content.optString(TEXT));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    if (Linkify.addLinks(valueTV, Linkify.ALL)) {
        if (!allowInteractions)
            valueTV.setMovementMethod(null);
    }

    frame.addView(valueTV);
}

From source file:com.github.xizzhu.simpletooltip.sample.MainActivity.java

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

    setContentView(R.layout.activity_main);
    findViewById(R.id.top_left_button).setOnClickListener(new View.OnClickListener() {
        @Override/* w w w . j  av a2 s . c  om*/
        public void onClick(View v) {
            showToolTipView(v, Gravity.RIGHT, "Simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.blue));
        }
    });
    findViewById(R.id.top_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.BOTTOM, "It is yet another very simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.green));
        }
    });
    findViewById(R.id.central_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.END, "It is a very simple tool tip in the center!",
                    ContextCompat.getColor(MainActivity.this, R.color.magenta));
        }
    });
    findViewById(R.id.bottom_left_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.TOP, "Tool tip, once more!",
                    ContextCompat.getColor(MainActivity.this, R.color.maroon));
        }
    });
    findViewById(R.id.bottom_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.LEFT, "Magical tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.navy));
        }
    });

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipViewWithParent((Button) v, Gravity.BOTTOM);
        }
    };
    findViewById(R.id.button1).setOnClickListener(listener);
    findViewById(R.id.button2).setOnClickListener(listener);
    findViewById(R.id.button3).setOnClickListener(listener);
    findViewById(R.id.button4).setOnClickListener(listener);
    findViewById(R.id.button5).setOnClickListener(listener);
    findViewById(R.id.button6).setOnClickListener(listener);
    findViewById(R.id.button7).setOnClickListener(listener);

    showToolTipView(findViewById(R.id.central_button), Gravity.START, "A simple tool tip!",
            ContextCompat.getColor(MainActivity.this, R.color.magenta), 750L);
}

From source file:biz.mosil.demo.navigationdrawer.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drw_layout);
    //  Drawer ?/*from  ww  w .  j a  v a 2  s .  c  om*/
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, //  Drawer Toggle ???
            R.drawable.ic_drawer, // Drawer  Icon
            R.string.open_left_drawer, // Drawer ??
            R.string.close_left_drawer // Drawer ??
    ) {
        // ??
        @Override
        public void onDrawerOpened(View drawerView) {
            //  Title 
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                getSupportActionBar().setTitle(R.string.open_right_drawer);
            } else {
                getSupportActionBar().setTitle(R.string.open_left_drawer);
            }

            if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                // ???
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.RIGHT);
            } else {
                // ???
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.LEFT);
            }
        }

        // ??
        @Override
        public void onDrawerClosed(View drawerView) {
            if (mCurrentMenuItemPosition > -1) {
                getSupportActionBar().setTitle(MENU_ITEMS[mCurrentMenuItemPosition]);
            } else {
                //  Title  APP ??
                getSupportActionBar().setTitle(R.string.app_name);
            }

            if (mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                // 
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
            } else if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                // ?
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            } else {
                // ?
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.LEFT);
                mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
            }
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    //  Up Button (? Logo )
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    //  Up Button 
    getSupportActionBar().setHomeButtonEnabled(true);

    setDrawerMenu();
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.IMObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//from   w  w  w  .j a  va 2  s . c  o m
    TextView valueTV = new TextView(context);
    valueTV.setText("IM:" + content.optString(TEXT));
    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.jakewharton.behavior.drawer.BehaviorDelegate.java

BehaviorDelegate(CoordinatorLayout parent, View child, int gravity) {
    this.parent = parent;
    this.child = child;

    int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(parent));
    this.isLeft = absGravity == Gravity.LEFT;

    float density = parent.getResources().getDisplayMetrics().density;
    float minVel = MIN_FLING_VELOCITY * density;

    dragger = ViewDragHelper.create(parent, this);
    dragger.setEdgeTrackingEnabled(isLeft ? ViewDragHelper.EDGE_LEFT : ViewDragHelper.EDGE_RIGHT);
    dragger.setMinVelocity(minVel);//from w w  w  .  j a  va  2s  .c  o  m

    scrimDrawer = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2
            ? new ContentScrimDrawer.JellyBeanMr2(parent)
            : new ContentScrimDrawer.Base(parent, child);
}

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   w w  w . j a v  a  2  s . 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);
}