@Override protected void onCreateSubMenuPanel(CMenuItem moreItem) { if (mMenuPanel != null && mMenuPanel.isShowing()) { if (moreItem.hasSubMenu()) { updateMenuItem(moreItem); } else { mMenuPanel.dismiss(); } return; } if (moreItem == null || !moreItem.hasSubMenu()) { return; } if (mMenuPanel == null) { mMenuPanelLayout = new SubMenuPanelLayout(getContext()); mMenuPanelLayout.setBackgroundColor(Color.BLUE); FrameLayout.LayoutParams p = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); p.gravity = Gravity.BOTTOM; p.bottomMargin = getBottom() - getTop(); FrameLayout container = new FrameLayout(getContext()); container.addView(mMenuPanelLayout, p); mMenuPanel = new PopupWindow(container, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); // mMenuPanel.setOutsideTouchable(true); mMenuPanel.setTouchable(true); mMenuPanel.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); mMenuPanel.setTouchInterceptor( new OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { final int menuPanelTop = mMenuPanelLayout.getTop(); final Rect r = new Rect(); mMenuPanelLayout.getDrawingRect(r); final Rect menuPanelRect = new Rect( r.left, r.top + menuPanelTop, r.right, r.bottom + menuPanelTop); if (!menuPanelRect.contains((int) motionEvent.getX(), (int) motionEvent.getY())) { if (mMenuPanel != null && mMenuPanel.isShowing()) { mMenuPanel.dismiss(); } } return false; } }); } if (!mMenuPanel.isShowing()) { updateMenuItem(moreItem); mMenuPanel.showAtLocation(this, Gravity.BOTTOM | Gravity.LEFT, 0, 0); } }
public static void manageAds(Activity activity) { final PackageManager pm = activity.getPackageManager(); // get a list of installed apps. List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); boolean yboTvProFound = false; for (ApplicationInfo info : packages) { if (PACKAGE_PRO.equals(info.packageName)) { yboTvProFound = true; break; } } // Look up the AdView as a resource and load a request. AdView adView = (AdView) activity.findViewById(R.id.adView); if (yboTvProFound) { View layout = activity.findViewById(R.id.ad_container); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) layout.getLayoutParams(); layoutParams.bottomMargin = 0; layout.setLayoutParams(layoutParams); adView.setVisibility(View.GONE); } else { adView.loadAd(new AdRequest.Builder().build()); } }
private void fixLayoutInternal() { if (getParentActivity() == null) { return; } WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); columnsCount = 2; if (!AndroidUtilities.isTablet() && (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) { columnsCount = 4; } listAdapter.notifyDataSetChanged(); if (dropDownContainer != null) { if (!AndroidUtilities.isTablet()) { FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); dropDownContainer.setLayoutParams(layoutParams); } if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { dropDown.setTextSize(18); } else { dropDown.setTextSize(20); } } }
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final View view = LayoutInflater.from(context).inflate(R.layout.item_feed, parent, false); final CellFeedViewHolder cellFeedViewHolder = new CellFeedViewHolder(view); if (viewType == VIEW_TYPE_DEFAULT) { cellFeedViewHolder.btnComments.setOnClickListener(this); cellFeedViewHolder.btnMore.setOnClickListener(this); cellFeedViewHolder.ivFeedCenter.setOnClickListener(this); cellFeedViewHolder.btnLike.setOnClickListener(this); cellFeedViewHolder.ivUserProfile.setOnClickListener(this); } else if (viewType == VIEW_TYPE_LOADER) { View bgView = new View(context); bgView.setLayoutParams( new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); bgView.setBackgroundColor(0x77ffffff); cellFeedViewHolder.vImageRoot.addView(bgView); cellFeedViewHolder.vProgressBg = bgView; FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(loadingViewSize, loadingViewSize); params.gravity = Gravity.CENTER; SendingProgressView sendingProgressView = new SendingProgressView(context); sendingProgressView.setLayoutParams(params); cellFeedViewHolder.vImageRoot.addView(sendingProgressView); cellFeedViewHolder.vSendingProgress = sendingProgressView; } return cellFeedViewHolder; }
/** * Create a new BalloonOverlayView. * * @param context - The activity context. * @param balloonBottomOffset - The bottom padding (in pixels) to be applied when rendering this * view. */ public BalloonOverlayView(Context context, int balloonBottomOffset) { super(context); mCxt = context; setPadding(10, 0, 10, balloonBottomOffset); mLayout = new LinearLayout(context); mLayout.setVisibility(VISIBLE); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.balloon_overlay, mLayout); mTitle = (TextView) v.findViewById(R.id.balloon_item_title); mList = (ListView) v.findViewById(R.id.visitList); mIcon = (ImageView) v.findViewById(R.id.type_icon); ImageView close = (ImageView) v.findViewById(R.id.close_img_button); close.setOnClickListener( new OnClickListener() { public void onClick(View v) { mLayout.setVisibility(GONE); } }); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.NO_GRAVITY; addView(mLayout, params); }
private void initActionButton() { actionButton = new ImageView(mapActivity); int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size); int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(btnSize, btnSize); int marginRight = btnSize / 4; params.setMargins( 0, landscape ? 0 : topPad - 2 * btnSize, marginRight, landscape ? marginRight : 0); params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT; actionButton.setLayoutParams(params); actionButton.setScaleType(ScaleType.CENTER); actionButton.setImageDrawable( mapActivity.getResources().getDrawable(R.drawable.map_my_location)); actionButton.setBackgroundDrawable( mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue)); hideActionButton(); actionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (getMyApplication().accessibilityEnabled()) { mapActivity.getMapActions().whereAmIDialog(); } else { mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); } hideDashboard(); } }); }
public Loading(Context ctx) { super(ctx); // Window window = this.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); window.setBackgroundDrawableResource(R.color.transparent); this.setContentView(R.layout.dialog_loading); FrameLayout.LayoutParams rlp = new FrameLayout.LayoutParams( ((QAppSp) ctx.getApplicationContext()).getQWindow().getWidth() - 20, RelativeLayout.LayoutParams.WRAP_CONTENT); rlp.setMargins(10, 0, 10, 0); this.findViewById(R.id.dialog_loading_layout).setLayoutParams(rlp); // ivOut = this.findViewById(R.id.dialog_loading_out); ivIn = this.findViewById(R.id.dialog_loading_in); // LinearInterpolator li = new LinearInterpolator(); // 线性效果 animOut.setDuration(500); animOut.setRepeatCount(Animation.INFINITE); animOut.setInterpolator(li); animIn.setDuration(500); animIn.setRepeatCount(Animation.INFINITE); animIn.setInterpolator(li); }
private void showThumbnail(Bitmap thumbnail) { ImageView view = new ImageView(context); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(getThumbnailSize()); params.gravity = Gravity.CENTER; view.setImageBitmap(thumbnail); frame.addView(view, params); }
private void updateIndicatorPosition(int position, float positionOffset) { // 現在の位置のタブのView final View view = mTrack.getChildAt(position); // 現在の位置の次のタブのView、現在の位置が最後のタブのときはnull final View view2 = position == (mTrack.getChildCount() - 1) ? null : mTrack.getChildAt(position + 1); // 現在の位置のタブの左端座標取得 int left = view.getLeft(); // 現在の位置のタブの横幅 int width = view.getWidth(); // 現在の位置の次のタブの横幅 int width2 = view2 == null ? width : view2.getWidth(); // インディケータの幅 // width2 × スライドした割合 + (width × スライドした割合 - 1) int indicatorWidth = (int) (width2 * positionOffset + width * (1 - positionOffset)); // インディケータの左端の位置 // 今選択中のタブの左端 + width * スライドした割合 int indicatorLeft = (int) (left + positionOffset * width); // インディケータの幅と左端の位置をセット final FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) mIndicator.getLayoutParams(); layoutParams.width = indicatorWidth; layoutParams.setMargins(indicatorLeft, 0, 0, 0); mIndicator.setLayoutParams(layoutParams); // インディケータが画面に入るように、タブの領域をスクロール mTrackScroller.scrollTo(indicatorLeft - mIndicatorOffset, 0); mIndicator.setBackgroundColor(getResources().getColor(R.color.ferrari_red)); }
public static ViewOverlayPreJellybean getOverlay(ViewGroup sceneRoot) { if (sceneRoot != null) { ViewGroup group = sceneRoot; while (group.getId() != android.R.id.content && group.getParent() != null && group.getParent() instanceof ViewGroup) { group = (ViewGroup) group.getParent(); } for (int i = 0; i < group.getChildCount(); i++) { View child = group.getChildAt(i); if (child instanceof ViewOverlayPreJellybean) { return (ViewOverlayPreJellybean) child; } } final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); params.gravity = Gravity.FILL; ViewOverlayPreJellybean viewOverlay = new ViewOverlayPreJellybean(sceneRoot.getContext()); group.addView(viewOverlay, params); return viewOverlay; } else { return null; } }
private void createProgressBarForRouting() { FrameLayout parent = (FrameLayout) mapView.getParent(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP); DisplayMetrics dm = getResources().getDisplayMetrics(); params.topMargin = (int) (60 * dm.density); final ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal); pb.setIndeterminate(false); pb.setMax(100); pb.setLayoutParams(params); pb.setVisibility(View.GONE); parent.addView(pb); app.getRoutingHelper() .setProgressBar( new RouteCalculationProgressCallback() { @Override public void updateProgress(int progress) { pb.setVisibility(View.VISIBLE); pb.setProgress(progress); } @Override public void finish() { pb.setVisibility(View.GONE); } }); }
public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params); DisplayMetrics dm = getResources().getDisplayMetrics(); final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm); TextView v = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v.setLayoutParams(params); v.setLayoutParams(params); v.setGravity(Gravity.CENTER); v.setText("PAGE09 "); v.setTextSize((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 12, dm)); // WebView webviewtest= new WebView(getActivity()); // webviewtest.loadUrl("file:///android_asset/1.html"); // fl.addView(webviewtest); fl.addView(v); return fl; }
private void updatelayoutIconVideo() { // update for video ion big LayoutParams lpImageBox; if (mImage != null) { lpImageBox = (LayoutParams) mImage.getLayoutParams(); } else { lpImageBox = (LayoutParams) mLLTitle.getLayoutParams(); } int width = lpImageBox.width; int height = lpImageBox.height; FrameLayout.LayoutParams lpLLTitle = (LayoutParams) mLLTitle.getLayoutParams(); int heightPortion = height - lpLLTitle.height; if (heightPortion == 0) { height = getBoxSupposeHeight(); heightPortion = height - lpLLTitle.height; } FrameLayout.LayoutParams lpVideoIcon = (LayoutParams) mIvVideoIconBig.getLayoutParams(); if (lpLLTitle.height > height / 2) { lpVideoIcon.gravity = Gravity.CENTER_VERTICAL; lpVideoIcon.leftMargin = width / 2 - lpVideoIcon.width / 2; } if (Math.abs(heightPortion) > height / 3) { lpVideoIcon.gravity = Gravity.CENTER_HORIZONTAL; lpVideoIcon.topMargin = heightPortion / 2 - lpVideoIcon.height / 2; } mIvVideoIconBig.setLayoutParams(lpVideoIcon); mIvVideoIconBig.setVisibility(VISIBLE); }
public void showTags() { clearTags(); if (!mShowTags) return; if (videoTags == null) return; for (int i = 0; i < videoTags.size(); i++) { VideoTag videoTag = videoTags.get(i); TextView textView; if (i < tagViews.size()) { textView = (TextView) tagViews.get(i); } else { textView = new TextView(getContext()); textView.setOnTouchListener(listener); textView.setTag(VIDEO_TAG_VIEW_TAG); tagViews.add(textView); } textView.setText(videoTag.getText()); // position int left = (int) (videoTag.getX() * getSize()); int top = (int) (videoTag.getY() * getSize()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(left, top, 0, 0); textView.setLayoutParams(params); addView(textView); } }
/** * Sets {@code LayoutAdjustment} and {@code narrowMode}. * * <p>They are highly dependent on one another so this method sets both at the same time. This * decision makes caller-side simpler. */ public void setLayoutAdjustmentAndNarrowMode( LayoutAdjustment layoutAdjustment, boolean narrowMode) { checkInflated(); this.layoutAdjustment = layoutAdjustment; this.narrowMode = narrowMode; // If on narrowMode, the view is always shown with full-width regard less of given // layoutAdjustment. LayoutAdjustment temporaryAdjustment = narrowMode ? LayoutAdjustment.FILL : layoutAdjustment; View view = getForegroundFrame(); FrameLayout.LayoutParams layoutParams = FrameLayout.LayoutParams.class.cast(view.getLayoutParams()); Resources resources = getResources(); layoutParams.width = temporaryAdjustment == LayoutAdjustment.FILL ? resources.getDisplayMetrics().widthPixels : getSideAdjustedWidth(); layoutParams.gravity = Gravity.BOTTOM; if (temporaryAdjustment == LayoutAdjustment.LEFT) { layoutParams.gravity |= Gravity.LEFT; } else if (temporaryAdjustment == LayoutAdjustment.RIGHT) { layoutParams.gravity |= Gravity.RIGHT; } view.setLayoutParams(layoutParams); leftFrameStubProxy.setFrameVisibility( temporaryAdjustment == LayoutAdjustment.RIGHT ? VISIBLE : GONE); rightFrameStubProxy.setFrameVisibility( temporaryAdjustment == LayoutAdjustment.LEFT ? VISIBLE : GONE); // Set candidate and desciption text size. float candidateTextSize = layoutAdjustment == LayoutAdjustment.FILL ? resources.getDimension(R.dimen.candidate_text_size) : resources.getDimension(R.dimen.candidate_text_size_aligned_layout); float descriptionTextSize = layoutAdjustment == LayoutAdjustment.FILL ? resources.getDimension(R.dimen.candidate_description_text_size) : resources.getDimension(R.dimen.candidate_description_text_size_aligned_layout); getCandidateView().setCandidateTextDimension(candidateTextSize, descriptionTextSize); getSymbolInputView().setCandidateTextDimension(candidateTextSize, descriptionTextSize); getConversionCandidateWordContainerView().setCandidateTextDimension(candidateTextSize); // In narrow mode, hide software keyboard and show narrow status bar. getCandidateView().setNarrowMode(narrowMode); if (narrowMode) { getKeyboardFrame().setVisibility(GONE); getNarrowFrame().setVisibility(VISIBLE); } else { getKeyboardFrame().setVisibility(VISIBLE); getNarrowFrame().setVisibility(GONE); resetKeyboardFrameVisibility(); } updateInputFrameHeight(); updateBackgroundColor(); }
public synchronized void fillFreeList(int animationLen) { final Context ctx = getContext(); final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(mCellSize, mCellSize); while (!mFreeList.isEmpty()) { Point pt = mFreeList.iterator().next(); mFreeList.remove(pt); final int i = pt.x; final int j = pt.y; if (mCells[j * mColumns + i] != null) continue; final ImageView v = new ImageView(ctx); v.setOnClickListener( new OnClickListener() { @Override public void onClick(View view) { place(v, true); postDelayed( new Runnable() { public void run() { fillFreeList(); } }, DURATION / 2); } }); final int c = random_color(); v.setBackgroundColor(c); final float which = frand(); final Drawable d; if (which < 0.0005f) { d = mDrawables.get(pick(XXRARE_PASTRIES)); } else if (which < 0.005f) { d = mDrawables.get(pick(XRARE_PASTRIES)); } else if (which < 0.5f) { d = mDrawables.get(pick(RARE_PASTRIES)); } else if (which < 0.7f) { d = mDrawables.get(pick(PASTRIES)); } else { d = null; } if (d != null) { v.getOverlay().add(d); } lp.width = lp.height = mCellSize; addView(v, lp); place(v, pt, false); if (animationLen > 0) { final float s = (Integer) v.getTag(TAG_SPAN); v.setScaleX(0.5f * s); v.setScaleY(0.5f * s); v.setAlpha(0f); v.animate().withLayer().scaleX(s).scaleY(s).alpha(1f).setDuration(animationLen); } } }
protected void addProgressbar() { mProgressBar = new ProgressBar(this); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; addContentView(mProgressBar, params); mProgressBar.setVisibility(View.INVISIBLE); }
private void showProgress() { ProgressBar view = new ProgressBar(context); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; view.setIndeterminate(true); frame.addView(view, params); }
protected FrameLayout.LayoutParams createLayoutParams() { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.gravity = Gravity.CENTER; return layoutParams; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); characters = new ArrayList<CharTextView>(); mainLayout = new LinearLayout(this); setContentView(mainLayout); mainLayout.setOrientation(LinearLayout.VERTICAL); mainLayout.setId(442); grid = new GridLayout(this); GridLayout.LayoutParams gridParams = new GridLayout.LayoutParams(GridLayout.spec(3), GridLayout.spec(7)); grid.setId(444); int counter = 0; for (int i = 0; i < 7; ++i) { for (int j = 0; j < 2; ++j) { CharTextView iv = new CharTextView(this); Bitmap joeAvatar = BitmapFactory.decodeResource(getResources(), R.drawable.joe); Character joe = new Character(joeAvatar, "Joe Nash", 24, "United Kingdom"); iv.setCharacterCell(joe); iv.setId(50 + counter); GridLayout.LayoutParams buttonparams = new GridLayout.LayoutParams(GridLayout.spec(j), GridLayout.spec(i)); buttonparams.height = 200; buttonparams.width = 150; iv.setOnClickListener(this); grid.addView(iv, buttonparams); characters.add(iv); counter++; } } heroLayout = new FrameLayout(this); heroLayout.setId(443); FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); frameParams.height = 600; ImageView portrait = new ImageView(this); portrait.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.joenash)); heroLayout.addView(portrait); Button fightButton = new Button(this); fightButton.setText(R.string.fight); ViewGroup.LayoutParams buttonParams = new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); buttonParams.height = 150; buttonParams.width = 650; mainLayout.addView(heroLayout, frameParams); mainLayout.addView(grid, gridParams); mainLayout.addView(fightButton, buttonParams); // znameto // heroLayout.setBackground(); // String variable = "variable" // int Button = getResources().getIdentifier(variable, "drawable", getPackageName()); }
protected void setState(boolean state) { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( mToggleForegroundButton.getWidth(), mToggleForegroundButton.getHeight()); mToggleBackgroundButton.setEnabled(state); mToggleForegroundButton.setEnabled(state); params.gravity = (state ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL; mToggleForegroundButton.setLayoutParams(params); }
public void setBadgeMargin( int leftDipMargin, int topDipMargin, int rightDipMargin, int bottomDipMargin) { FrameLayout.LayoutParams params = (LayoutParams) getLayoutParams(); params.leftMargin = dip2Px(leftDipMargin); params.topMargin = dip2Px(topDipMargin); params.rightMargin = dip2Px(rightDipMargin); params.bottomMargin = dip2Px(bottomDipMargin); setLayoutParams(params); }
/** display platform list */ @SuppressLint("NewApi") public void afterPlatformListGot() { int size = platformList == null ? 0 : platformList.length; views = new View[size]; final int dp_24 = dipToPx(getContext(), 24); LayoutParams lpItem = new LayoutParams(dp_24, dp_24); final int dp_9 = dipToPx(getContext(), 9); lpItem.setMargins(0, 0, dp_9, 0); FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); lpMask.gravity = Gravity.LEFT | Gravity.TOP; int selection = 0; for (int i = 0; i < size; i++) { FrameLayout fl = new FrameLayout(getContext()); fl.setLayoutParams(lpItem); if (i >= size - 1) { fl.setLayoutParams(new LayoutParams(dp_24, dp_24)); } llPlat.addView(fl); fl.setOnClickListener(this); ImageView iv = new ImageView(getContext()); iv.setScaleType(ScaleType.CENTER_INSIDE); iv.setImageBitmap(getPlatLogo(platformList[i])); iv.setLayoutParams( new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); fl.addView(iv); views[i] = new View(getContext()); views[i].setBackgroundColor(0xcfffffff); views[i].setOnClickListener(this); String platformName = platformList[i].getName(); for (Platform plat : platforms) { if (platformName.equals(plat.getName())) { views[i].setVisibility(View.INVISIBLE); selection = i; } } views[i].setLayoutParams(lpMask); fl.addView(views[i]); } final int postSel = selection; UIHandler.sendEmptyMessageDelayed( 0, 333, new Callback() { @SuppressLint("NewApi") public boolean handleMessage(Message msg) { HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent(); hsv.scrollTo(postSel * (dp_24 + dp_9), 0); return false; } }); }
private void prepareLayouts(int move) { if (move == 0) { reuseView(centerView); reuseView(leftView); reuseView(rightView); for (int a = currentMessageNum - 1; a < currentMessageNum + 2; a++) { if (a == currentMessageNum - 1) { leftView = getViewForMessage(a, true); } else if (a == currentMessageNum) { centerView = getViewForMessage(a, true); } else if (a == currentMessageNum + 1) { rightView = getViewForMessage(a, true); } } } else if (move == 1) { reuseView(rightView); rightView = centerView; centerView = leftView; leftView = getViewForMessage(currentMessageNum - 1, true); } else if (move == 2) { reuseView(leftView); leftView = centerView; centerView = rightView; rightView = getViewForMessage(currentMessageNum + 1, true); } else if (move == 3) { if (rightView != null) { int offset = ((FrameLayout.LayoutParams) rightView.getLayoutParams()).leftMargin; reuseView(rightView); rightView = getViewForMessage(currentMessageNum + 1, false); int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) rightView.getLayoutParams(); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; layoutParams.width = widht; layoutParams.leftMargin = offset; rightView.setLayoutParams(layoutParams); rightView.invalidate(); } } else if (move == 4) { if (leftView != null) { int offset = ((FrameLayout.LayoutParams) leftView.getLayoutParams()).leftMargin; reuseView(leftView); leftView = getViewForMessage(0, false); int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) leftView.getLayoutParams(); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT; layoutParams.width = widht; layoutParams.leftMargin = offset; leftView.setLayoutParams(layoutParams); leftView.invalidate(); } } }
/** * 更新fouccusview的中心 * * @param x * @param y */ public void updateFouccusCenter(float x, float y, Rect rect) { // mFocus.setBackgroundColor(Color.WHITE); mFocus.setVisibility(View.VISIBLE); FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams(); lp.width = rect.width(); lp.height = rect.height(); lp.leftMargin = (int) (x - rect.width() / 2); lp.topMargin = (int) (y - rect.height() / 2); setLayoutParams(lp); }
private void display(Context cx) { ArrayList<Block> blocks = new ArrayList<Block>(); counter = coorX = coorY = 0; calculateAllCells(cx); pattern = getDisplayPattern(); for (int i = 0; i < pattern.size(); i++) { ArrayList<Cell> boxCells = new ArrayList<Cell>(); for (int j = 0; j < pattern.get(i).size(); j++) { Cell c = cells.get(pattern.get(i).get(j)); boxCells.add(c); } Block block = mBlockPattern.getBlock(boxCells); block.cells = boxCells; blocks.add(block); } double maxHeightsLocal[] = {0, 0, 0, 0}; for (int i = 0; i < blocks.size(); i++) { CellView cv = new CellView(cx); View view = mAdapter.getView(postion, null, frameLayout); cv.addView(view); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams((int) blocks.get(i).width, (int) blocks.get(i).height); params.setMargins( (int) blocks.get(i).x1, (int) blocks.get(i).y1 + (int) blocks.get(i).getHeightShift(maxHeights), 0, 0); frameLayout.addView(cv, params); cells.get(i).setCellView(cv); postion++; view.setTag(postion); setViewListeners(view); if (postion >= mAdapter.getCount()) return; // Get the max height that the cells of the box occupy for (int j = 0; j < blocks.get(i).cells.size(); j++) { maxHeightsLocal[blocks.get(i).cells.get(j).coorX] += blocks.get(i).cells.get(j).getHeight(); } } for (int i = 0; i < 4; i++) maxHeights[i] += maxHeightsLocal[i]; cells.clear(); }
/** * Constructs a new Op09CarrierText instance with Context. * * @param context A Context object. */ public Op09CarrierText(Context context) { this.mContext = context; mNumOfSub = SIMHelper.getSlotCount(); final Resources res = mContext.getResources(); mNetworkNameDefault = res.getString(R.string.lockscreen_carrier_default); mSimMissingDefault = res.getString(R.string.lockscreen_missing_sim_message_short); mCarrierLabelHeight = res.getDimensionPixelSize(R.dimen.carrier_label_height); mCloseHandleHeight = res.getDimensionPixelSize(R.dimen.close_handle_height); final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, mCarrierLabelHeight, Gravity.BOTTOM); params.bottomMargin = mCloseHandleHeight; mCarrierLayout = (LinearLayout) View.inflate(mContext, R.layout.sys_carrier_label, null); mCarrierLayout.setLayoutParams(params); // the carrier and carrier divider number is defined in layout: carrier_label.xml mCarrierView = new TextView[MAX_CARRIER_TEXT_NUM]; mCarrierDivider = new TextView[MAX_CARRIER_TEXT_NUM - 1]; mCarrierView[0] = (TextView) mCarrierLayout.findViewById(R.id.carrier_1); mCarrierView[1] = (TextView) mCarrierLayout.findViewById(R.id.carrier_2); mCarrierView[2] = (TextView) mCarrierLayout.findViewById(R.id.carrier_3); mCarrierView[3] = (TextView) mCarrierLayout.findViewById(R.id.carrier_4); mCarrierDivider[0] = (TextView) mCarrierLayout.findViewById(R.id.carrier_divider_1); mCarrierDivider[1] = (TextView) mCarrierLayout.findViewById(R.id.carrier_divider_2); mCarrierDivider[2] = (TextView) mCarrierLayout.findViewById(R.id.carrier_divider_3); for (int i = 0; i < mNumOfSub; i++) { mCarrierView[i].setText(mNetworkNameDefault); if (i < mNumOfSub - 1) { mCarrierDivider[i].setText("|"); } } if (mNumOfSub == 2) { mCarrierView[0].setGravity(Gravity.END); mCarrierView[1].setGravity(Gravity.START); } if (DEBUG) { Log.d( TAG, "Op09CarrierText, mNumOfSub=" + mNumOfSub + " , mNetworkNameDefault=" + mNetworkNameDefault + " , mSimMissingDefault=" + mSimMissingDefault); } }
@Override public void onResize(int mode, int delta) { if (mTarget == null) return; if (mResizeFrame == null) return; int w = getMeasuredWidth() - (getPaddingLeft() + getPaddingRight()); int h = getMeasuredHeight() - (getPaddingTop() + getPaddingBottom()); int minWidth = (w / mCols) + (w / mCols) / 2; int minHeight = (h / mRows) + (h / mRows) / 2; FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mResizeFrame.getLayoutParams(); switch (mode) { case Gravity.LEFT: float newpos = mResizeFrame.getX() + delta; if ((delta < 0 && newpos < (getPaddingLeft() * -1)) || (delta > 0 && newpos > (mResizeFrame.getX() + params.width - minWidth))) { return; } mResizeFrame.setX(newpos); params.width -= delta; break; case Gravity.RIGHT: if ((delta < 0 && ((params.width + delta) < minWidth)) || (delta > 0 && (mResizeFrame.getX() + delta + params.width) > (getPaddingLeft() + getMeasuredWidth()))) { return; } params.width += delta; break; case Gravity.TOP: newpos = mResizeFrame.getY() + delta; if ((delta < 0 && newpos < (getPaddingTop() * -1)) || (delta > 0 && newpos > (mResizeFrame.getY() + params.height - minHeight))) { return; } mResizeFrame.setY(newpos); params.height -= delta; break; case Gravity.BOTTOM: if ((delta < 0 && ((params.height + delta) < minHeight)) || (delta > 0 && (mResizeFrame.getY() + delta + params.height) > (getPaddingTop() + getMeasuredHeight()))) { return; } params.height += delta; break; default: break; } mResizeFrame.setLayoutParams(params); }
/** * Prepare the given view to be shown. This might include adjusting {@link * FrameLayout.LayoutParams} before inserting. */ protected void prepareView(View view) { // Take requested dimensions from child, but apply default gravity. FrameLayout.LayoutParams requested = (FrameLayout.LayoutParams) view.getLayoutParams(); if (requested == null) { requested = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); } requested.gravity = Gravity.CENTER; view.setLayoutParams(requested); }
@Override public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { // Translate overlay and image float flexibleRange = mFlexibleSpaceImageHeight - mActionBarSize; int minOverlayTransitionY = mActionBarSize - mOverlayView.getHeight(); ViewHelper.setTranslationY( mOverlayView, ScrollUtils.getFloat(-scrollY, minOverlayTransitionY, 0)); ViewHelper.setTranslationY( mImageView, ScrollUtils.getFloat(-scrollY / 2, minOverlayTransitionY, 0)); // Change alpha of overlay ViewHelper.setAlpha(mOverlayView, ScrollUtils.getFloat((float) scrollY / flexibleRange, 0, 1)); // Scale title text float scale = 1 + ScrollUtils.getFloat( (flexibleRange - scrollY) / flexibleRange, 0, MAX_TEXT_SCALE_DELTA); ViewHelper.setPivotX(mTitleView, 0); ViewHelper.setPivotY(mTitleView, 0); ViewHelper.setScaleX(mTitleView, scale); ViewHelper.setScaleY(mTitleView, scale); // Translate title text int maxTitleTranslationY = (int) (mFlexibleSpaceImageHeight - mTitleView.getHeight() * scale); int titleTranslationY = maxTitleTranslationY - scrollY; ViewHelper.setTranslationY(mTitleView, titleTranslationY); // Translate FAB int maxFabTranslationY = mFlexibleSpaceImageHeight - mFab.getHeight() / 2; float fabTranslationY = ScrollUtils.getFloat( -scrollY + mFlexibleSpaceImageHeight - mFab.getHeight() / 2, mActionBarSize - mFab.getHeight() / 2, maxFabTranslationY); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // On pre-honeycomb, ViewHelper.setTranslationX/Y does not set margin, // which causes FAB's OnClickListener not working. FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mFab.getLayoutParams(); lp.leftMargin = mOverlayView.getWidth() - mFabMargin - mFab.getWidth(); lp.topMargin = (int) fabTranslationY; mFab.requestLayout(); } else { ViewHelper.setTranslationX(mFab, mOverlayView.getWidth() - mFabMargin - mFab.getWidth()); ViewHelper.setTranslationY(mFab, fabTranslationY); } // Show/hide FAB if (fabTranslationY < mFlexibleSpaceShowFabOffset) { hideFab(); } else { showFab(); } }