List of usage examples for android.view Gravity LEFT
int LEFT
To view the source code for android.view Gravity LEFT.
Click Source Link
From source file:com.anl.wxb.jieqi.view.VerticalSeekBarWrapper.java
private void onSizeChangedTraditionalRotation(int w, int h, int oldw, int oldh) { final VerticalSeekBar seekBar = getChildSeekBar(); if (seekBar != null) { final LayoutParams lp = (LayoutParams) seekBar.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = h;//w w w . j a v a2 s . com seekBar.setLayoutParams(lp); seekBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); int seekBarWidth = seekBar.getMeasuredWidth(); seekBar.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY)); lp.gravity = Gravity.TOP | Gravity.LEFT; lp.leftMargin = (w - seekBarWidth) / 2; seekBar.setLayoutParams(lp); } super.onSizeChanged(w, h, oldw, oldh); }
From source file:com.manning.androidhacks.hack016.MainActivity.java
public void bottomLeft(View v) { Toast toast = Toast.makeText(this, "Bottom Left!", Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM | Gravity.LEFT, 0, 0); toast.show();/*from w w w . j a v a 2s .c o m*/ }
From source file:io.github.importre.android.chromeadb.ChromeAdbService.java
private void addMouseCursor() { if (mCursorImage == null) { mCursorImage = new ImageView(this); mCursorImage.setImageResource(R.drawable.cursor); }/*from w ww.ja v a 2 s . c o m*/ if (mLayoutParam == null) { mLayoutParam = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, PixelFormat.TRANSLUCENT); mLayoutParam.gravity = Gravity.LEFT | Gravity.TOP; mLayoutParam.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; } if (mWindowManager == null) { mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE); mWindowManager.addView(mCursorImage, mLayoutParam); } }
From source file:com.king.android.common.widget.badge.BGADragBadgeView.java
private void initLayoutParams() { mLayoutParams = new WindowManager.LayoutParams(); mLayoutParams.gravity = Gravity.LEFT + Gravity.TOP; mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; mLayoutParams.format = PixelFormat.TRANSLUCENT; mLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; mLayoutParams.width = mWindowManager.getDefaultDisplay().getWidth(); mLayoutParams.height = mWindowManager.getDefaultDisplay().getHeight(); }
From source file:com.example.android.navigationdrawerexample.DrawerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drawer); mTitle = mDrawerTitle = getTitle();//from w ww .j a va 2 s . co m mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mDrawerLayout.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 mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ getSupportActionBar(), /* ActionBar of the hosting Activity */ mDrawerLayout, /* 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() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:com.anysoftkeyboard.ui.settings.MainSettingsActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main_ui);/*from ww w. ja v a2s .c om*/ mTitle = mDrawerTitle = getTitle(); mDrawerRootLayout = (DrawerLayout) findViewById(R.id.main_root_layout); mDrawerRootLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.LEFT); mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerRootLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer icon to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description */ R.string.drawer_close /* "close drawer" description */ ) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); ActivityCompat.invalidateOptionsMenu(MainSettingsActivity.this);// creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { getSupportActionBar().setTitle(mDrawerTitle); ActivityCompat.invalidateOptionsMenu(MainSettingsActivity.this);// creates call to onPrepareOptionsMenu() } }; // Set the drawer toggle as the DrawerListener mDrawerRootLayout.setDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); AnyApplication.getConfig().addChangedListener(menuExtraUpdaterOnConfigChange); }
From source file:com.example.android.navigationdrawerexample.LeftDrawerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_left_drawer); mTitle = mDrawerTitle = getTitle();// w w w .j ava2s . c om mPlanetTitles = getResources().getStringArray(R.array.planets_array); mHorizonDrawerLayout = (HorizonDrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens mHorizonDrawerLayout.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 mHorizonDrawerToggle = new ActionBarHorizonDrawerToggle(this, /* host Activity */ getSupportActionBar(), /* ActionBar of the hosting Activity */ mHorizonDrawerLayout, /* 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() } }; mHorizonDrawerToggle.setGravity(Gravity.LEFT); mHorizonDrawerLayout.setDrawerListener(mHorizonDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:am.project.x.business.drawables.linedrawable.LineDrawableActivity.java
@SuppressLint("RtlHardcoded") @Override/*from w w w.j a va2 s .c o m*/ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { switch (position) { default: case 0: drawable.setGravity(Gravity.BOTTOM); break; case 1: drawable.setGravity(Gravity.LEFT); break; case 2: drawable.setGravity(Gravity.TOP); break; case 3: drawable.setGravity(Gravity.RIGHT); break; case 4: drawable.setGravity(Gravity.CENTER_HORIZONTAL); break; case 5: drawable.setGravity(Gravity.CENTER_VERTICAL); break; case 6: drawable.setGravity(Gravity.TOP | Gravity.BOTTOM); break; case 7: drawable.setGravity(Gravity.LEFT | Gravity.RIGHT); break; } }
From source file:com.example.android.navigationdrawerexample.RightDrawerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_right_drawer); mTitle = mDrawerTitle = getTitle();//from w w w . j a v a 2s . c o m mPlanetTitles = getResources().getStringArray(R.array.planets_array); mHorizonDrawerLayout = (HorizonDrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.right_drawer); // set a custom shadow that overlays the main content when the drawer opens mHorizonDrawerLayout.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 mHorizonDrawerToggle = new ActionBarHorizonDrawerToggle(this, /* host Activity */ getSupportActionBar(), /* ActionBar of the hosting Activity */ mHorizonDrawerLayout, /* 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() } }; mHorizonDrawerToggle.setGravity(Gravity.RIGHT); mHorizonDrawerLayout.setDrawerListener(mHorizonDrawerToggle); if (savedInstanceState == null) { selectItem(0); } }
From source file:am.project.x.business.drawables.combinationdrawable.CombinationDrawableActivity.java
@SuppressLint("RtlHardcoded") @Override/*from w ww. ja v a 2 s . co 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; } }