Java Code Examples for android.view.ViewGroup.LayoutParams

The following are top voted examples for showing how to use android.view.ViewGroup.LayoutParams. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: aos-Video   File: NewVideosActionProvider.java   View source code 7 votes vote down vote up
public DropDownWindow(View anchor, View contentView) {
    super(anchor.getContext());
    mAnchor = anchor;
    final Resources r = anchor.getResources();
    setBackgroundDrawable(r.getDrawable(R.drawable.dialog_full_holo_dark));
    setWidth(r.getDimensionPixelSize(R.dimen.new_videos_action_dropdown_width)); // Takes too much space on tablets when using LayoutParams.WRAP_CONTENT
    setHeight(LayoutParams.WRAP_CONTENT);

    setContentView(contentView);

    setTouchable(true);
    setFocusable(true);

    // listen to anchor getting removed (e.g. activity destroyed)
    // -> dismiss() self so we don't keep this window open
    anchor.addOnAttachStateChangeListener(this);
}
 
Example 2
Project: AOSP-Kayboard-7.1.2   File: LatinIME.java   View source code 7 votes vote down vote up
private void showOptionDialog(final AlertDialog dialog) {
    final IBinder windowToken = mKeyboardSwitcher.getMainKeyboardView().getWindowToken();
    if (windowToken == null) {
        return;
    }

    final Window window = dialog.getWindow();
    final WindowManager.LayoutParams lp = window.getAttributes();
    lp.token = windowToken;
    lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
    window.setAttributes(lp);
    window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);

    mOptionsDialog = dialog;
    dialog.show();
}
 
Example 3
Project: Mobike   File: EditPage.java   View source code 6 votes vote down vote up
public void setActivity(Activity activity) {
		super.setActivity(activity);
		if (isDialogMode()) {
			System.err.println("Theme classic does not support dialog mode!");
//			activity.setTheme(android.R.style.Theme_Dialog);
//			activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
//			if (Build.VERSION.SDK_INT >= 11) {
//				try {
//					ReflectHelper.invokeInstanceMethod(activity, "setFinishOnTouchOutside", false);
//				} catch (Throwable e) {}
//			}
		}

		activity.getWindow().setSoftInputMode(
				WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE |
				WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
	}
 
Example 4
Project: YiZhi   File: EditPage.java   View source code 6 votes vote down vote up
@Override
protected int onSetTheme(int resid, boolean atLaunch) {
	if (isDialogMode()) {
		activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
		if (Build.VERSION.SDK_INT >= 11) {
			try {
				ReflectHelper.invokeInstanceMethod(activity, "setFinishOnTouchOutside", false);
			} catch (Throwable e) {}
		}
		return android.R.style.Theme_Dialog;
	} else {
		activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
				| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
	}
	return super.onSetTheme(resid, atLaunch);
}
 
Example 5
Project: boohee_v5.6   File: PullToRefreshView.java   View source code 6 votes vote down vote up
public void setAdapter(PullToRefreshAdatper pullToRefreshAdatper) {
    this.adapter = pullToRefreshAdatper;
    removeAllViews();
    this.bodyView = (View) pullToRefreshAdatper.getBodyView();
    LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
    layoutParams.addRule(9, -1);
    layoutParams.addRule(11, -1);
    layoutParams.addRule(10, -1);
    addView(this.bodyView, layoutParams);
    this.headerView = pullToRefreshAdatper.getHeaderView();
    this.headerView.measure(0, 0);
    this.headerHeight = this.headerView.getMeasuredHeight();
    layoutParams = new RelativeLayout.LayoutParams(-2, this.headerHeight);
    layoutParams.addRule(9, -1);
    layoutParams.addRule(11, -1);
    layoutParams.addRule(10, -1);
    layoutParams.topMargin = -this.headerHeight;
    addView(this.headerView, layoutParams);
}
 
Example 6
Project: letv   File: MyDownloadActivity.java   View source code 6 votes vote down vote up
private void doTabPageIndicatorAnimator(int start, int end) {
    this.mTabPIValueAnimator = ValueAnimator.ofInt(new int[]{start, end});
    this.mTabPIValueAnimator.addUpdateListener(new AnimatorUpdateListener(this) {
        final /* synthetic */ MyDownloadActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onAnimationUpdate(ValueAnimator animation) {
            int value = ((Integer) animation.getAnimatedValue()).intValue();
            LayoutParams layoutParams = this.this$0.mIndicator.getLayoutParams();
            layoutParams.height = value;
            this.this$0.mIndicator.setLayoutParams(layoutParams);
        }
    });
    this.mTabPIValueAnimator.start();
}
 
Example 7
Project: weex-uikit   File: WXViewUtils.java   View source code 6 votes vote down vote up
public static boolean onScreenArea(View view) {
  if (view == null || view.getVisibility() != View.VISIBLE) {
    return false;
  }

  int[] p = new int[2];
  view.getLocationOnScreen(p);
  LayoutParams lp = view.getLayoutParams();
  int viewH = 0;
  if (lp != null) {
    viewH = lp.height;
  } else {
    viewH = view.getHeight();
  }

  return (p[1] > 0 && (p[1] - WXViewUtils.getScreenHeight(WXEnvironment.sApplication) < 0))
         || (viewH + p[1] > 0 && p[1] <= 0);
}
 
Example 8
Project: CXJPadProject   File: ThankDialog.java   View source code 6 votes vote down vote up
@SuppressWarnings("deprecation")
public ThankDialog create() {
          LayoutInflater inflater = (LayoutInflater) context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          final ThankDialog dialog = new ThankDialog(context, ResourceUtils.getIdByName(context, "style", "sobot_Dialog"));
          dialog.setCanceledOnTouchOutside(false);
          View layout = inflater.inflate(ResourceUtils.getIdByName(context, "layout", "sobot_thank_dialog_layout"), null);
          dialog.addContentView(layout, new LayoutParams(
                  LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
          
          if (message != null) {
              ((TextView) layout.findViewById(ResourceUtils.getIdByName(context, "id", "sobot_message"))).setText(message);
          } 
          dialog.setContentView(layout);
          return dialog;
      }
 
Example 9
Project: ProgressManager   File: a.java   View source code 6 votes vote down vote up
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
    event.setClassName(getClass().getName());
    event.setPackageName(getPackageName());

    LayoutParams params = getWindow().getAttributes();
    boolean isFullScreen = (params.width == LayoutParams.MATCH_PARENT) &&
            (params.height == LayoutParams.MATCH_PARENT);
    event.setFullScreen(isFullScreen);

    CharSequence title = getTitle();
    if (!TextUtils.isEmpty(title)) {
        event.getText().add(title);
    }

    return true;
}
 
Example 10
Project: Leanplum-Android-SDK   File: BaseMessageDialog.java   View source code 6 votes vote down vote up
private RelativeLayout createTitleView(Context context) {
  RelativeLayout view = new RelativeLayout(context);
  view.setLayoutParams(new LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

  TextView title = new TextView(context);
  title.setPadding(0, SizeUtil.dp5, 0, SizeUtil.dp5);
  title.setGravity(Gravity.CENTER);
  title.setText(options.getTitle());
  title.setTextColor(options.getTitleColor());
  title.setTextSize(TypedValue.COMPLEX_UNIT_SP, SizeUtil.textSize0);
  title.setTypeface(null, Typeface.BOLD);
  RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
  layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);
  layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
  title.setLayoutParams(layoutParams);

  view.addView(title, title.getLayoutParams());
  return view;
}
 
Example 11
Project: letv   File: PullToRefreshBase.java   View source code 6 votes vote down vote up
protected void updateUIForMode() {
    LinearLayout.LayoutParams lp = getLoadingLayoutLayoutParams();
    if (this == this.mHeaderLayout.getParent()) {
        removeView(this.mHeaderLayout);
    }
    if (this.mMode.showHeaderLoadingLayout()) {
        addViewInternal(this.mHeaderLayout, 0, lp);
    }
    if (this == this.mFooterLayout.getParent()) {
        removeView(this.mFooterLayout);
    }
    if (this.mMode.showFooterLoadingLayout()) {
        addViewInternal(this.mFooterLayout, lp);
    }
    refreshLoadingViewsSize();
    this.mCurrentMode = this.mMode != Mode.BOTH ? this.mMode : Mode.PULL_FROM_START;
}
 
Example 12
Project: SLTableView   File: OptionsPopupWindow.java   View source code 6 votes vote down vote up
public OptionsPopupWindow(Context context) {
    super(context);
    this.setWidth(LayoutParams.FILL_PARENT);
    this.setHeight(LayoutParams.WRAP_CONTENT);
    this.setBackgroundDrawable(new BitmapDrawable());// 这样设置才能点击屏幕外dismiss窗口
    this.setOutsideTouchable(true);
    this.setAnimationStyle(R.style.timepopwindow_anim_style);

    LayoutInflater mLayoutInflater = LayoutInflater.from(context);
    rootView = mLayoutInflater.inflate(R.layout.pw_options, null);
    // -----确定和取消按钮
    btnSubmit = rootView.findViewById(R.id.btnSubmit);
    btnSubmit.setTag(TAG_SUBMIT);
    btnCancel = rootView.findViewById(R.id.btnCancel);
    btnCancel.setTag(TAG_CANCEL);
    btnSubmit.setOnClickListener(this);
    btnCancel.setOnClickListener(this);
    // ----转轮
    final View optionspicker = rootView.findViewById(R.id.optionspicker);
    ScreenInfo screenInfo = new ScreenInfo((Activity) context);
    wheelOptions = new WheelOptions(optionspicker);

    wheelOptions.screenheight = screenInfo.getHeight();

    setContentView(rootView);
}
 
Example 13
Project: cordova-plugin-x5-webview   File: X5WebChromeClient.java   View source code 6 votes vote down vote up
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
return mVideoProgressView;
}
 
Example 14
Project: weex-3d-map   File: WXRenderStatement.java   View source code 6 votes vote down vote up
WXComponent createBodyOnDomThread(WXDomObject dom) {
  if (mWXSDKInstance == null) {
    return null;
  }
  WXDomObject domObject = new WXDomObject();
  WXDomObject.prepareGod(domObject);
  mGodComponent = (WXVContainer) WXComponentFactory.newInstance(mWXSDKInstance, domObject, null);
  mGodComponent.createView(null, -1);
  if (mGodComponent == null) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("rootView failed!");
    }
    //TODO error callback
    return null;
  }
  FrameLayout frameLayout = (FrameLayout) mGodComponent.getHostView();
  ViewGroup.LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  frameLayout.setLayoutParams(layoutParams);
  frameLayout.setBackgroundColor(Color.TRANSPARENT);

  WXComponent component = generateComponentTree(dom, mGodComponent);
  mGodComponent.addChild(component);
  mRegistry.put(component.getRef(), component);
  return component;
}
 
Example 15
Project: boohee_v5.6   File: AsyncImageView.java   View source code 6 votes vote down vote up
private int[] getSize() {
    int width = getWidth();
    int height = getHeight();
    if (width == 0 || height == 0) {
        LayoutParams layoutParams = getLayoutParams();
        if (layoutParams != null) {
            width = layoutParams.width;
            height = layoutParams.height;
        }
    }
    if (width == 0 || r0 == 0) {
        measure(0, 0);
        width = getMeasuredWidth();
        height = getMeasuredHeight();
    }
    return new int[]{width, height};
}
 
Example 16
Project: Ec2m   File: UiSizeUtil.java   View source code 5 votes vote down vote up
/**
     *
     * @param view
     * @param width (-1 MatchParent,-2 WrapContent,other)
     * @param height(-1 MatchParent,-2 WrapContent,other)
     */
    public static void LayoutChange(View view,int width,int height){

//    1、获取控件所在的布局
        LayoutParams para = view.getLayoutParams();//获取按钮的布局
//    2、修改布局中的height,width属性
        if (width==MATCH_PARENT){
            para.width=LayoutParams.MATCH_PARENT;
        }else if(width==WRAP_CONTENT) {
            para.width=LayoutParams.WRAP_CONTENT;//修改宽度
        }else if(width ==NO_CHANGE){

        }else {
            para.width = width;
        }

        if (height==MATCH_PARENT){
            para.height=LayoutParams.MATCH_PARENT;
        }else if(height==WRAP_CONTENT) {
            para.height=LayoutParams.WRAP_CONTENT;//修改宽度
        }else if(height ==NO_CHANGE){

        }else {
            para.height=height;//修改高度
        }
//    3、重新设置修改后的布局给控件
        view.setLayoutParams(para); //设置修改后的布局。
    }
 
Example 17
Project: LoRaWAN-Smart-Parking   File: CordovaChromeClient.java   View source code 5 votes vote down vote up
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {            
        // Create a new Loading view programmatically.
        
        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);   
        layout.addView(bar);
        
        mVideoProgressView = layout;
    }
return mVideoProgressView; 
}
 
Example 18
Project: LiuAGeAndroid   File: EditPage.java   View source code 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = ResHelper.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 19
Project: ucar-weex-core   File: LayoutParamsProperty.java   View source code 5 votes vote down vote up
@Override
public Integer get(View object) {
  LayoutParams layoutParams;
  if (object != null && (layoutParams = object.getLayoutParams()) != null) {
    return getProperty(layoutParams);
  }
  return 0;
}
 
Example 20
Project: CSipSimple   File: ActionBarSherlockNative.java   View source code 5 votes vote down vote up
@Override
public void setContentView(View view, LayoutParams params) {
    if (ActionBarSherlock.DEBUG) Log.d(TAG, "[setContentView] view: " + view + ", params: " + params);

    mActivity.getWindow().setContentView(view, params);
    initActionBar();
}
 
Example 21
Project: cordova.plugins.X5WebView   File: X5WebChromeClient.java   View source code 5 votes vote down vote up
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a newx Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
return mVideoProgressView;
}
 
Example 22
Project: browser   File: BrowserActivity.java   View source code 5 votes vote down vote up
/**
 * turns on fullscreen mode in the app
 *
 * @param enabled
 *            whether to enable fullscreen or not
 */
public void setFullscreen(boolean enabled) {
	Window win = getWindow();
	WindowManager.LayoutParams winParams = win.getAttributes();
	final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
	if (enabled) {
		winParams.flags |= bits;
	} else {
		winParams.flags &= ~bits;
		if (mCustomView != null) {
			mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
		} else {
			mBrowserFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
		}
	}
	win.setAttributes(winParams);

	if(mToolbarLayout!=null){
		mToolbarLayout.setVisibility(View.GONE);
	}

	if(shortcutToolbar!=null){
		shortcutToolbar.setVisibility(View.GONE);
	}
	if(fullscreenCancelBtn!=null){
		fullscreenCancelBtn.setVisibility(View.VISIBLE);
	}

}
 
Example 23
Project: letv   File: AuthActivity.java   View source code 5 votes vote down vote up
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    try {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            finish();
            return;
        }
        try {
            this.d = extras.getString(b);
            String string = extras.getString("params");
            if (k.a(string)) {
                Method method;
                super.requestWindowFeature(1);
                this.f = new Handler(getMainLooper());
                View linearLayout = new LinearLayout(getApplicationContext());
                LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
                linearLayout.setOrientation(1);
                setContentView(linearLayout, layoutParams);
                this.c = new WebView(getApplicationContext());
                layoutParams.weight = 1.0f;
                this.c.setVisibility(0);
                linearLayout.addView(this.c, layoutParams);
                WebSettings settings = this.c.getSettings();
                settings.setUserAgentString(settings.getUserAgentString() + k.c(getApplicationContext()));
                settings.setRenderPriority(RenderPriority.HIGH);
                settings.setSupportMultipleWindows(true);
                settings.setJavaScriptEnabled(true);
                settings.setSavePassword(false);
                settings.setJavaScriptCanOpenWindowsAutomatically(true);
                settings.setMinimumFontSize(settings.getMinimumFontSize() + 8);
                settings.setAllowFileAccess(false);
                settings.setTextSize(TextSize.NORMAL);
                this.c.setVerticalScrollbarOverlay(true);
                this.c.setWebViewClient(new b());
                this.c.setWebChromeClient(new a());
                this.c.setDownloadListener(new a(this));
                this.c.loadUrl(string);
                if (VERSION.SDK_INT >= 7) {
                    try {
                        method = this.c.getSettings().getClass().getMethod("setDomStorageEnabled", new Class[]{Boolean.TYPE});
                        if (method != null) {
                            method.invoke(this.c.getSettings(), new Object[]{Boolean.valueOf(true)});
                        }
                    } catch (Exception e) {
                    }
                }
                try {
                    method = this.c.getClass().getMethod("removeJavascriptInterface", new Class[0]);
                    if (method != null) {
                        method.invoke(this.c, new Object[]{"searchBoxJavaBridge_"});
                        return;
                    }
                    return;
                } catch (Exception e2) {
                    return;
                }
            }
            finish();
        } catch (Exception e3) {
            finish();
        }
    } catch (Exception e4) {
        finish();
    }
}
 
Example 24
Project: treasure   File: PhotoViewActivity.java   View source code 5 votes vote down vote up
@Override
public View instantiateItem(ViewGroup container, int position) {
	PhotoView photoView = new PhotoView(container.getContext());
	Glide.with(getApplicationContext())
			.load(mImageUrlList.get(position))
			.into(photoView);

	// Now just add PhotoView to ViewPager and return it
	container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

	return photoView;
}
 
Example 25
Project: topnews   File: EditPage.java   View source code 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = ResHelper.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 26
Project: letv   File: AuthDialog.java   View source code 5 votes vote down vote up
private void c() {
    d();
    LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
    this.k = new c(this.l);
    this.k.setLayoutParams(layoutParams);
    this.f = new FrameLayout(this.l);
    layoutParams.gravity = 17;
    this.f.setLayoutParams(layoutParams);
    this.f.addView(this.k);
    this.f.addView(this.h);
    setContentView(this.f);
}
 
Example 27
Project: easyfilemanager   File: DocumentsActivity.java   View source code 5 votes vote down vote up
private void initProtection() {

		if(mAuthenticated || !SettingsActivity.isPinEnabled(this)){
			return;
		}
        final Dialog d = new Dialog(this, R.style.Theme_Document_DailogPIN);
        d.setContentView(new PinViewHelper((LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE), null, null) {
            public void onEnter(String password) {
                super.onEnter(password);
                if (SettingsActivity.checkPin(DocumentsActivity.this, password)) {
                	mAuthenticated = true;
                	d.dismiss();
                }
                else {
                    showError(R.string.incorrect_pin);
                }
            }

            public void onCancel() {
                super.onCancel();
                finish();
                d.dismiss();
            }
        }.getView(), new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        
        PINDialogFragment pinFragment = new PINDialogFragment();
        pinFragment.setDialog(d);
        pinFragment.setCancelable(false);
        pinFragment.show(getFragmentManager(), "PIN Dialog");
	}
 
Example 28
Project: 19porn   File: PlayerActivity.java   View source code 5 votes vote down vote up
private void doBrightnessTouch(float y_changed) {
      if (mTouchAction != TOUCH_NONE && mTouchAction != TOUCH_BRIGHTNESS)
          return;
if (mIsFirstBrightnessGesture) initBrightnessTouch();
      mTouchAction = TOUCH_BRIGHTNESS;

      float delta = - y_changed / mSurfaceYDisplayRange * 0.07f;

      WindowManager.LayoutParams lp = getWindow().getAttributes();
      float bright = Math.min(Math.max(lp.screenBrightness + delta, 0.01f), 1);
      lp.screenBrightness = bright;

      getWindow().setAttributes(lp);
      showBrightnessTipInfoTimeout((int)(bright * 100) + "%", 1000);
  }
 
Example 29
Project: boohee_v5.6   File: BottomSheetBehavior.java   View source code 5 votes vote down vote up
public static <V extends View> BottomSheetBehavior<V> from(V view) {
    LayoutParams params = view.getLayoutParams();
    if (params instanceof CoordinatorLayout.LayoutParams) {
        Behavior behavior = ((CoordinatorLayout.LayoutParams) params).getBehavior();
        if (behavior instanceof BottomSheetBehavior) {
            return (BottomSheetBehavior) behavior;
        }
        throw new IllegalArgumentException("The view is not associated with BottomSheetBehavior");
    }
    throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
}
 
Example 30
Project: Mybilibili   File: EditPage.java   View source code 5 votes vote down vote up
/** 动态适配编辑界面的高度 */
public void run() {
	int height = svContent.getChildAt(0).getHeight();
	RelativeLayout.LayoutParams lp = ResHelper.forceCast(svContent.getLayoutParams());
	if (height > maxBodyHeight && lp.height != maxBodyHeight) {
		lp.height = maxBodyHeight;
		svContent.setLayoutParams(lp);
	} else if (height < maxBodyHeight && lp.height == maxBodyHeight) {
		lp.height = LayoutParams.WRAP_CONTENT;
		svContent.setLayoutParams(lp);
	}
}
 
Example 31
Project: FireFiles   File: AppRate.java   View source code 5 votes vote down vote up
private void displayViews(ViewGroup mainView) {
    if(null != viewGroup){
        viewGroup.setVisibility(View.VISIBLE);
        viewGroup.addView(mainView);
    }
    else{
        LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
        activity.addContentView(mainView, params);
    }

    Animation fadeInAnimation = AnimationUtils.loadAnimation(activity, android.R.anim.fade_in);
    mainView.startAnimation(fadeInAnimation);

    if (onShowListener != null) onShowListener.onRateAppShowing();
}
 
Example 32
Project: topnews   File: EditPageLand.java   View source code 5 votes vote down vote up
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
Example 33
Project: ProgressManager   File: a.java   View source code 5 votes vote down vote up
final void attach(Context context, ActivityThread aThread,
                  Instrumentation instr, IBinder token, int ident,
                  Application application, Intent intent, ActivityInfo info,
                  CharSequence title, Activity parent, String id,
                  NonConfigurationInstances lastNonConfigurationInstances,
                  Configuration config, String referrer, IVoiceInteractor voiceInteractor,
                  Window window) {
    attachBaseContext(context);

    mFragments.attachHost(null /*parent*/);

    mWindow = new PhoneWindow(this, window);
    mWindow.setWindowControllerCallback(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
        mWindow.setSoftInputMode(info.softInputMode);
    }
    if (info.uiOptions != 0) {
        mWindow.setUiOptions(info.uiOptions);
    }
    mUiThread = Thread.currentThread();

    mMainThread = aThread;
    mInstrumentation = instr;
    mToken = token;
    mIdent = ident;
    mApplication = application;
    mIntent = intent;
    mReferrer = referrer;
    mComponent = intent.getComponent();
    mActivityInfo = info;
    mTitle = title;
    mParent = parent;
    mEmbeddedID = id;
    mLastNonConfigurationInstances = lastNonConfigurationInstances;
    if (voiceInteractor != null) {
        if (lastNonConfigurationInstances != null) {
            mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
        } else {
            mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this,
                    Looper.myLooper());
        }
    }

    mWindow.setWindowManager(
            (WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
            mToken, mComponent.flattenToString(),
            (info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
    if (mParent != null) {
        mWindow.setContainer(mParent.getWindow());
    }
    mWindowManager = mWindow.getWindowManager();
    mCurrentConfig = config;
}
 
Example 34
Project: OSchina_resources_android   File: CommonDialog.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    if (TDevice.isTablet()) {
        int maxWidth = (int) TDevice.dp2px(360f);
        if (maxWidth < TDevice.getScreenWidth()) {
            WindowManager.LayoutParams params = getWindow().getAttributes();
            params.width = maxWidth;
            getWindow().setAttributes(params);
        }
    }
}
 
Example 35
Project: MyFire   File: EditPagePort.java   View source code 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = R.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_HEIGHT;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example 36
Project: POCenter   File: EditPageLand.java   View source code 5 votes vote down vote up
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px_1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
	llBottom.addView(v, lp);
}
 
Example 37
Project: letv   File: LetvUtil.java   View source code 5 votes vote down vote up
public static void setListViewHeightBasedOnChildren(ListView listView) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter != null) {
        int totalHeight = 0;
        for (int i = 0; i < listAdapter.getCount(); i++) {
            View listItem = listAdapter.getView(i, null, listView);
            listItem.measure(0, 0);
            totalHeight += listItem.getMeasuredHeight();
        }
        LayoutParams params = listView.getLayoutParams();
        params.height = (listView.getDividerHeight() * (listAdapter.getCount() - 1)) + totalHeight;
        listView.setLayoutParams(params);
    }
}
 
Example 38
Project: chromium-for-android-56-debug-video   File: ChromeFullscreenManager.java   View source code 5 votes vote down vote up
private void applyMarginToFullChildViews(ViewGroup contentView, float margin) {
    for (int i = 0; i < contentView.getChildCount(); i++) {
        View child = contentView.getChildAt(i);
        if (!(child.getLayoutParams() instanceof FrameLayout.LayoutParams)) continue;
        FrameLayout.LayoutParams layoutParams =
                (FrameLayout.LayoutParams) child.getLayoutParams();

        if (layoutParams.height == LayoutParams.MATCH_PARENT
                && layoutParams.topMargin != (int) margin) {
            layoutParams.topMargin = (int) margin;
            child.requestLayout();
            TraceEvent.instant("FullscreenManager:child.requestLayout()");
        }
    }
}
 
Example 39
Project: cordova-vuetify   File: SystemWebChromeClient.java   View source code 5 votes vote down vote up
@Override
/**
 * Ask the host application for a custom progress view to show while
 * a <video> is loading.
 * @return View The progress view.
 */
public View getVideoLoadingProgressView() {

    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.

        // create the linear layout
        LinearLayout layout = new LinearLayout(parentEngine.getView().getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(parentEngine.getView().getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);

        mVideoProgressView = layout;
    }
return mVideoProgressView;
}
 
Example 40
Project: yyox   File: EditPageLand.java   View source code 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = ResHelper.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}