List of usage examples for android.widget FrameLayout setX
public void setX(float x)
From source file:tv.ouya.sdk.OuyaUnityPlugin.java
private static void updateSafeArea(float progress) { // bring in by % float percent = 0.1f; float ratio = 1 - (1 - progress) * percent; float halfRatio = 1 - (1 - progress) * percent * 0.5f; float maxWidth = getDisplayWidth(); float maxHeight = getDisplayHeight(); Activity activity = IOuyaActivity.GetActivity(); FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content); LayoutParams layout = content.getLayoutParams(); layout.width = (int) (maxWidth * ratio); layout.height = (int) (maxHeight * ratio); content.setLayoutParams(layout);/*from ww w.ja va 2 s .co m*/ content.setX(maxWidth - maxWidth * halfRatio); content.setY(maxHeight - maxHeight * halfRatio); }
From source file:potboiler.client.PotsActivity.java
License:asdf
private void createDrawerMenu() { mMenuItems = getResources().getStringArray(R.array.menu_sections); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawer = (LinearLayout) findViewById(R.id.left_drawer); mCommandsList = (ListView) findViewById(R.id.commands); User user = PreferenceUtils.getUser(this); ((TextView) findViewById(R.id.name)).setText(user.username); Bitmap bitmap = ImageUtils.getImageFromFile(this, FileUtils.getImagesPath(this) + user.serverId); if (bitmap != null) { /*Bitmap circleBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); //from w ww . j a v a2s . c om BitmapShader shader = new BitmapShader (bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); Paint paint = new Paint(); paint.setShader(shader); paint.setAntiAlias(true); Canvas c = new Canvas(circleBitmap); c.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2, bitmap.getWidth() / 2, paint);*/ int w = bitmap.getWidth(); int h = bitmap.getHeight(); int radius = Math.min(h / 2, w / 2); Bitmap circleBitmap = Bitmap.createBitmap(w + 8, h + 8, Bitmap.Config.ARGB_8888); Paint paint = new Paint(); paint.setAntiAlias(true); Canvas c = new Canvas(circleBitmap); c.drawARGB(0, 0, 0, 0); paint.setStyle(Paint.Style.FILL); c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); c.drawBitmap(bitmap, 4, 4, paint); paint.setXfermode(null); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.WHITE); paint.setStrokeWidth(3); c.drawCircle((w / 2) + 4, (h / 2) + 4, radius, paint); ((ImageView) findViewById(R.id.avatar)).setImageBitmap(circleBitmap); } mDrawerLayout.setScrimColor(getResources().getColor(android.R.color.transparent)); DrawerAdapter adapter = new DrawerAdapter(this, R.layout.item_drawer_list, R.id.title, mMenuItems); mCommandsList.setAdapter(adapter); mCommandsList.setOnItemClickListener(new DrawerItemClickListener()); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.pots, R.string.pots) { public void onDrawerClosed(View view) { super.onDrawerClosed(view); syncActionBarArrowState(); // invalidateOptionsMenu(); // mDrawerToggle.syncState(); // setRefreshMenu(); } public void onDrawerOpened(View drawerView) { // super.onDrawerClosed(drawerView); super.onDrawerOpened(drawerView); mDrawerToggle.setDrawerIndicatorEnabled(true); // invalidateOptionsMenu(); // mDrawerToggle.syncState(); // setRefreshMenu(); } @Override public void onDrawerSlide(View drawerView, float slideOffset) { super.onDrawerSlide(drawerView, slideOffset); float xPositionOpenDrawer = mCommandsList.getWidth(); float xPositionWindowContent = (slideOffset * xPositionOpenDrawer); FrameLayout mHostFragment = (FrameLayout) findViewById(R.id.content_frame); mHostFragment.setX(xPositionWindowContent); getActionBarView().setX(xPositionWindowContent); } }; mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.syncState(); getSupportFragmentManager().addOnBackStackChangedListener(mOnBackStackChangedListener); findViewById(R.id.signout).setOnClickListener(this); }
From source file:tv.ouya.sdk.CordovaOuyaPlugin.java
protected void setSafeArea(CallbackContext callback, final float progress) { final Activity activity = cordova.getActivity(); if (null != activity) { Runnable runnable = new Runnable() { public void run() { // bring in by % float percent = 0.1f; float ratio = 1 - (1 - progress) * percent; float halfRatio = 1 - (1 - progress) * percent * 0.5f; float maxWidth = getDisplayWidth(); float maxHeight = getDisplayHeight(); FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content); ViewGroup.LayoutParams layout = content.getLayoutParams(); layout.width = (int) (maxWidth * ratio); layout.height = (int) (maxHeight * ratio); content.setLayoutParams(layout); content.setX(maxWidth - maxWidth * halfRatio); content.setY(maxHeight - maxHeight * halfRatio); }/*w w w. j a v a 2s .c om*/ }; activity.runOnUiThread(runnable); } callback.success(); }