List of usage examples for android.view View requestLayout
@CallSuper public void requestLayout()
From source file:com.develop.autorus.MainActivity.java
public static void expand(final View v) { v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); final int targetHeight = v.getMeasuredHeight(); // Older versions of android (pre API 21) cancel animations for views with a height of 0. v.getLayoutParams().height = 1;// w ww . j av a 2 s . com v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density)); v.startAnimation(a); }
From source file:com.atwal.wakeup.battery.util.Utilities.java
public static void setMargins(View v, int left, int top, int right, int bottom) { if (v.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { ViewGroup.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); p.setMargins(left, top, right, bottom); v.requestLayout(); }/*from w w w. jav a 2 s .c o m*/ }
From source file:li.klass.fhem.fragments.core.BaseFragment.java
public void invalidate() { View view = getView(); if (view != null) { view.invalidate(); view.requestLayout(); } }
From source file:org.kevoree.platform.android.boot.view.ManagerUI.java
/** * Call requestLayout() recursively on each child view * contained into this view if it has any. Otherwise * the call will only be made on the given view * * @param view a View object/*from w w w.java 2s .com*/ */ private void doRequestLayout(View view) { ViewGroup vg = null; if (view instanceof ViewGroup) { vg = (ViewGroup) view; for (int i = 0; i < vg.getChildCount(); i++) { doRequestLayout(vg.getChildAt(i)); } } else { view.requestLayout(); } }
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static void updateFullscreenStatus(Activity pActivity, View pContentView, boolean pUseFullscreen) { T.UI();/*from w w w . j a v a 2 s . c om*/ if (pActivity.getWindow() != null) { if (pUseFullscreen) { pActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); pActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { pActivity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); pActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } pContentView.requestLayout(); } }
From source file:com.cleanwiz.applock.ui.BaseActivity.java
protected void setStatusBarMargin(View view) { if (Build.VERSION.SDK_INT < 19 || view == null || view.getLayoutParams() == null) { return;//from w ww . j ava 2s.c o m } if (view.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams(); lp.topMargin = lp.topMargin + getStatusBarHeight(this); view.requestLayout(); } else if (view.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) view.getLayoutParams(); lp.topMargin = lp.topMargin + getStatusBarHeight(this); view.requestLayout(); } else if (view.getLayoutParams() instanceof DrawerLayout.LayoutParams) { DrawerLayout.LayoutParams lp = (DrawerLayout.LayoutParams) view.getLayoutParams(); lp.topMargin = lp.topMargin + getStatusBarHeight(this); view.requestLayout(); } }
From source file:com.grarak.kerneladiutor.views.dialog.ViewPagerDialog.java
@Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { view.getViewTreeObserver().removeGlobalOnLayoutListener(this); ViewGroup.LayoutParams params = view.getLayoutParams(); params.height = mHeight;/*from w ww . jav a2 s. c o m*/ view.requestLayout(); } }); }
From source file:com.google.android.apps.santatracker.games.SplashActivity.java
@Override protected void onStart() { super.onStart(); // Orientation boolean gameIsLandscape = getIntent().getBooleanExtra(EXTRA_LANDSCAPE, false); boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int rotation = display.getRotation(); // Figure out how many degrees to rotate // Landscape always wants to be at 90degrees, portrait always wants to be at 0degrees float degreesToRotate = 0f; if (rotation == Surface.ROTATION_0) { degreesToRotate = gameIsLandscape && !isLandscape ? 90.0f : 0.0f; } else if (rotation == Surface.ROTATION_90) { degreesToRotate = gameIsLandscape && isLandscape ? 0f : -90f; } else if (rotation == Surface.ROTATION_180) { degreesToRotate = gameIsLandscape && !isLandscape ? -90f : -180f; } else if (rotation == Surface.ROTATION_270) { degreesToRotate = gameIsLandscape && isLandscape ? -180f : -270f; }//w w w . j a v a 2s .co m // On a TV, should always be 0 if (isRunningOnTV()) { degreesToRotate = 0f; } // Rotate, if necessary if (degreesToRotate != 0) { Point size = new Point(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { display.getRealSize(size); } else { display.getSize(size); } int w = size.x; int h = size.y; View mainLayout = findViewById(R.id.splash_layout); mainLayout.setRotation(degreesToRotate); mainLayout.setTranslationX((w - h) / 2); mainLayout.setTranslationY((h - w) / 2); ViewGroup.LayoutParams lp = mainLayout.getLayoutParams(); lp.height = w; lp.width = h; mainLayout.requestLayout(); } }
From source file:org.lib.ExpandableLinearLayout.java
private void setHeight(View view, int targetHeight) { LayoutParams lp = (LayoutParams) view.getLayoutParams(); if (targetHeight == 0) { view.setVisibility(GONE);/*from ww w . j a v a 2 s .c o m*/ } else { lp.height = lp.originalHeight; lp.weight = lp.originalWeight; view.requestLayout(); } if (listener != null) { listener.onExpansionUpdate(targetHeight == 0 ? 0f : 1f); } }
From source file:net.abcdroid.devfest12.ui.tablet.MapMultiPaneActivity.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); boolean landscape = (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE); LinearLayout spacerView = (LinearLayout) findViewById(R.id.map_detail_spacer); spacerView.setOrientation(landscape ? LinearLayout.HORIZONTAL : LinearLayout.VERTICAL); spacerView.setGravity(landscape ? Gravity.RIGHT : Gravity.BOTTOM); View popupView = findViewById(R.id.map_detail_popup); LinearLayout.LayoutParams popupLayoutParams = (LinearLayout.LayoutParams) popupView.getLayoutParams(); popupLayoutParams.width = landscape ? 0 : ViewGroup.LayoutParams.MATCH_PARENT; popupLayoutParams.height = landscape ? ViewGroup.LayoutParams.MATCH_PARENT : 0; popupView.setLayoutParams(popupLayoutParams); popupView.requestLayout(); }