/** Initializes the origin state of the layer */ private void initState() { mStickContainerToRightLeftOrMiddle.equals("left"); // Sticks container to right or left LayoutParams rlp = (LayoutParams) mSlidingLayer.getLayoutParams(); int textResource; Drawable d; if (mStickContainerToRightLeftOrMiddle.equals("right")) { textResource = R.string.swipe_right_label; d = getResources().getDrawable(R.drawable.container_rocket_right); rlp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); } else if (mStickContainerToRightLeftOrMiddle.equals("left")) { textResource = R.string.swipe_left_label; // d = getResources().getDrawable(R.drawable.container_rocket_left); rlp.addRule(RelativeLayout.ALIGN_PARENT_LEFT); } else if (mStickContainerToRightLeftOrMiddle.equals("top")) { textResource = R.string.swipe_up_label; d = getResources().getDrawable(R.drawable.container_rocket); mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_TOP); rlp.addRule(RelativeLayout.ALIGN_PARENT_TOP); rlp.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT; rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width); } else if (mStickContainerToRightLeftOrMiddle.equals("bottom")) { textResource = R.string.swipe_down_label; d = getResources().getDrawable(R.drawable.container_rocket); mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_BOTTOM); rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); rlp.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT; rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width); } else { textResource = R.string.swipe_label; d = getResources().getDrawable(R.drawable.container_rocket); rlp.addRule(RelativeLayout.CENTER_IN_PARENT); rlp.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT; } // d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); // swipeText.setCompoundDrawables(null, d, null, null); // swipeText.setText(getResources().getString(textResource)); mSlidingLayer.setLayoutParams(rlp); // Sets the shadow of the container if (mShowShadow) { mSlidingLayer.setShadowWidthRes(R.dimen.shadow_width); mSlidingLayer.setShadowDrawable(R.drawable.sidebar_shadow); } else { mSlidingLayer.setShadowWidth(20); mSlidingLayer.setShadowDrawable(null); } if (mShowOffset) { mSlidingLayer.setOffsetWidth(getResources().getDimensionPixelOffset(R.dimen.offset_width)); } else { mSlidingLayer.setOffsetWidth(0); } }
public void onStartPostProcessing() { LayoutInflater inflator = ApplicationScreen.instance.getLayoutInflater(); postProcessingView = inflator.inflate(R.layout.plugin_processing_sequence_postprocessing, null, false); mImgView = ((ImageView) postProcessingView.findViewById(R.id.sequenceImageHolder)); if (PreviewBmp != null) { PreviewBmp.recycle(); } paint = new Paint(); paint.setColor(0xFF00AAEA); paint.setStrokeWidth(5); paint.setPathEffect(new DashPathEffect(new float[] {5, 5}, 0)); PreviewBmp = mAlmaCLRShot.getPreviewBitmap(); if (PreviewBmp != null) { Matrix matrix = new Matrix(); matrix.postRotate(90); Bitmap rotated = Bitmap.createBitmap( PreviewBmp, 0, 0, PreviewBmp.getWidth(), PreviewBmp.getHeight(), matrix, true); mImgView.setImageBitmap(rotated); mImgView.setRotation( mCameraMirrored ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 0 : 180) : 0); } sequenceView = ((OrderControl) postProcessingView.findViewById(R.id.seqView)); final Bitmap[] thumbnailsArray = new Bitmap[thumbnails.size()]; for (int i = 0; i < thumbnailsArray.length; i++) { Bitmap bmp = thumbnails.get(i); Matrix matrix = new Matrix(); matrix.postRotate( mCameraMirrored ? ((mDisplayOrientation == 0 || mDisplayOrientation == 180) ? 270 : 90) : 90); Bitmap rotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true); thumbnailsArray[i] = rotated; } sequenceView.setContent(thumbnailsArray, this); LayoutParams lp = (LayoutParams) sequenceView.getLayoutParams(); lp.height = thumbnailsArray[0].getHeight(); sequenceView.setLayoutParams(lp); sequenceView.setRotation(mCameraMirrored ? 180 : 0); mHandler.sendEmptyMessage(MSG_END_OF_LOADING); }
@Override public void onGlobalLayout() { Rect r = new Rect(); baseRoot.getGlobalVisibleRect(r); // 进入Activity时会布局,第一次调用onGlobalLayout,先记录开始软键盘没有弹出时底部的位置 if (rootBottom == Integer.MIN_VALUE) { rootBottom = r.bottom; return; } // adjustResize,软键盘弹出后高度会变小 if (r.bottom < rootBottom) { // 按照键盘高度设置表情框和发送图片按钮框的高度 keyboardHeight = rootBottom - r.bottom; SystemConfigSp.instance().init(MessageActivity.this); SystemConfigSp.instance().setIntConfig(currentInputMethod, keyboardHeight); LayoutParams params = (LayoutParams) addOthersPanelView.getLayoutParams(); params.height = keyboardHeight; LayoutParams params1 = (LayoutParams) emoLayout.getLayoutParams(); params1.height = keyboardHeight; } }
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals("android.intent.action.INPUT_METHOD_CHANGED")) { currentInputMethod = Settings.Secure.getString( MessageActivity.this.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD); SystemConfigSp.instance() .setStrConfig(SystemConfigSp.SysCfgDimension.DEFAULTINPUTMETHOD, currentInputMethod); int height = SystemConfigSp.instance().getIntConfig(currentInputMethod); if (keyboardHeight != height) { keyboardHeight = height; addOthersPanelView.setVisibility(View.GONE); emoLayout.setVisibility(View.GONE); MessageActivity.this .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); messageEdt.requestFocus(); if (keyboardHeight != 0 && addOthersPanelView.getLayoutParams().height != keyboardHeight) { LayoutParams params = (LayoutParams) addOthersPanelView.getLayoutParams(); params.height = keyboardHeight; } if (keyboardHeight != 0 && emoLayout.getLayoutParams().height != keyboardHeight) { LayoutParams params = (LayoutParams) emoLayout.getLayoutParams(); params.height = keyboardHeight; } } else { addOthersPanelView.setVisibility(View.VISIBLE); emoLayout.setVisibility(View.VISIBLE); MessageActivity.this .getWindow() .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); messageEdt.requestFocus(); } } }
// by jmpessoa public void setLayoutAll(int idAnchor) { lparams.width = lpW; // matchParent; lparams.height = lpH; // wrapContent; lparams.setMargins(MarginLeft, MarginTop, marginRight, marginBottom); if (idAnchor > 0) { for (int i = 0; i < countAnchorRule; i++) { lparams.addRule(lparamsAnchorRule[i], idAnchor); } } for (int j = 0; j < countParentRule; j++) { lparams.addRule(lparamsParentRule[j]); } // this.setLayoutParams(lparams); }
protected View inflateRescueButton(View parent) { RelativeLayout rel = new RelativeLayout(getContext()); rel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); rel.addView(parent); int buttonSize = getContext().getResources().getDimensionPixelSize(R.dimen.puzzle_title_height); LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT | RelativeLayout.ALIGN_PARENT_TOP); params.width = buttonSize; params.height = buttonSize; View view = getRescueButton(); view.setLayoutParams(params); rel.addView(view); return rel; }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { mWidth = mContext.getResources().getDisplayMetrics().widthPixels; convertView = viewInflater.inflate(R.layout.view_grid_item_media_chooser, parent, false); holder = new ViewHolder(); holder.checkBoxTextView = (CheckedTextView) convertView.findViewById(R.id.checkTextViewFromMediaChooserGridItemRowView); holder.imageView = (ImageView) convertView.findViewById(R.id.imageViewFromMediaChooserGridItemRowView); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } LayoutParams imageParams = (LayoutParams) holder.imageView.getLayoutParams(); imageParams.width = mWidth / 2; imageParams.height = mWidth / 2; holder.imageView.setLayoutParams(imageParams); // set the status according to this Category item if (mIsFromVideo) { new VideoLoadAsync(videoFragment, holder.imageView, false, mWidth / 2) .executeOnExecutor( MediaAsync.THREAD_POOL_EXECUTOR, mGalleryModelList.get(position).url.toString()); } else { ImageLoadAsync loadAsync = new ImageLoadAsync(mContext, holder.imageView, mWidth / 2); loadAsync.executeOnExecutor( MediaAsync.THREAD_POOL_EXECUTOR, mGalleryModelList.get(position).url); } holder.checkBoxTextView.setChecked(mGalleryModelList.get(position).status); return convertView; }
// by jmpessoa public void setLayoutAll(int idAnchor) { lparams.width = lpW; // matchParent; lparams.height = lpH; // wrapContent; lparams.setMargins(MarginLeft, MarginTop, marginRight, marginBottom); if (idAnchor > 0) { // lparams.addRule(RelativeLayout.BELOW, id); // lparams.addRule(RelativeLayout.ALIGN_BASELINE, id) // lparams.addRule(RelativeLayout.LEFT_OF, id); //lparams.addRule(RelativeLayout.RIGHT_OF, id) for (int i = 0; i < countAnchorRule; i++) { lparams.addRule(lparamsAnchorRule[i], idAnchor); } } for (int j = 0; j < countParentRule; j++) { lparams.addRule(lparamsParentRule[j]); } // this.setLayoutParams(lparams); }
private void e() { this.k = (TextView) findViewById(R.id.search_devices_title); this.l = (TextView) findViewById(R.id.search_devices_info); this.k.setText(R.string.find_weight_scale_info); this.l.setText(a.f); this.m = (ImageView) findViewById(R.id.search_devices_mili_icon); this.m.setImageResource(R.drawable.mi_logo); this.j = (LinePieChartView) findViewById(R.id.searching_pie_chart); LayoutParams layoutParams = (LayoutParams) this.j.getLayoutParams(); layoutParams.width = (int) getResources().getDimension(R.dimen.draw_weight_icon_w); layoutParams.height = (int) getResources().getDimension(R.dimen.draw_weight_icon_w); this.j.a(4); this.j.d_(); findViewById(R.id.search_single_frame) .setBackgroundColor(getResources().getColor(R.color.bg_mode_weight)); this.n = (TextView) findViewById(R.id.search_devices_weight_value); this.o = findViewById(R.id.right_button); this.o.setOnClickListener(this); if (!DeviceSource.hasBindWeight()) { this.o.performClick(); } }
private void initialButton() { Display display = getWindowManager().getDefaultDisplay(); height = display.getHeight(); width = display.getWidth(); Log.v("width & height is:", String.valueOf(width) + ", " + String.valueOf(height)); params.height = 50; params.width = 50; // 设置边距 (int left, int top, int right, int bottom) params.setMargins(10, height - 98, 0, 0); buttonSleep = (Button) findViewById(R.id.button_composer_sleep); buttonSleep.setLayoutParams(params); buttonThought = (Button) findViewById(R.id.button_composer_thought); buttonThought.setLayoutParams(params); buttonMusic = (Button) findViewById(R.id.button_composer_music); buttonMusic.setLayoutParams(params); buttonPlace = (Button) findViewById(R.id.button_composer_place); buttonPlace.setLayoutParams(params); buttonWith = (Button) findViewById(R.id.button_composer_with); buttonWith.setLayoutParams(params); buttonCamera = (Button) findViewById(R.id.button_composer_camera); buttonCamera.setLayoutParams(params); buttonDelete = (Button) findViewById(R.id.button_friends_delete); buttonDelete.setLayoutParams(params); buttonDelete.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (isClick == false) { isClick = true; buttonDelete.startAnimation(animRotate(-45.0f, 0.5f, 0.45f)); buttonCamera.startAnimation( animTranslate(0.0f, -180.0f, 10, height - 240, buttonCamera, 80)); buttonWith.startAnimation( animTranslate(30.0f, -150.0f, 60, height - 230, buttonWith, 100)); buttonPlace.startAnimation( animTranslate(70.0f, -120.0f, 110, height - 210, buttonPlace, 120)); buttonMusic.startAnimation( animTranslate(80.0f, -110.0f, 150, height - 180, buttonMusic, 140)); buttonThought.startAnimation( animTranslate(90.0f, -60.0f, 175, height - 135, buttonThought, 160)); buttonSleep.startAnimation( animTranslate(170.0f, -30.0f, 190, height - 90, buttonSleep, 180)); } else { isClick = false; buttonDelete.startAnimation(animRotate(90.0f, 0.5f, 0.45f)); buttonCamera.startAnimation( animTranslate(0.0f, 140.0f, 10, height - 98, buttonCamera, 180)); buttonWith.startAnimation( animTranslate(-50.0f, 130.0f, 10, height - 98, buttonWith, 160)); buttonPlace.startAnimation( animTranslate(-100.0f, 110.0f, 10, height - 98, buttonPlace, 140)); buttonMusic.startAnimation( animTranslate(-140.0f, 80.0f, 10, height - 98, buttonMusic, 120)); buttonThought.startAnimation( animTranslate(-160.0f, 40.0f, 10, height - 98, buttonThought, 80)); buttonSleep.startAnimation( animTranslate(-170.0f, 0.0f, 10, height - 98, buttonSleep, 50)); } } }); buttonCamera.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonCamera.startAnimation(setAnimScale(2.5f, 2.5f)); buttonWith.startAnimation(setAnimScale(0.0f, 0.0f)); buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f)); buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f)); buttonThought.startAnimation(setAnimScale(0.0f, 0.0f)); buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); buttonWith.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonWith.startAnimation(setAnimScale(2.5f, 2.5f)); buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f)); buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f)); buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f)); buttonThought.startAnimation(setAnimScale(0.0f, 0.0f)); buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); buttonPlace.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonPlace.startAnimation(setAnimScale(2.5f, 2.5f)); buttonWith.startAnimation(setAnimScale(0.0f, 0.0f)); buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f)); buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f)); buttonThought.startAnimation(setAnimScale(0.0f, 0.0f)); buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); buttonMusic.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonMusic.startAnimation(setAnimScale(2.5f, 2.5f)); buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f)); buttonWith.startAnimation(setAnimScale(0.0f, 0.0f)); buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f)); buttonThought.startAnimation(setAnimScale(0.0f, 0.0f)); buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); buttonThought.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonThought.startAnimation(setAnimScale(2.5f, 2.5f)); buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f)); buttonWith.startAnimation(setAnimScale(0.0f, 0.0f)); buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f)); buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f)); buttonSleep.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); buttonSleep.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { buttonSleep.startAnimation(setAnimScale(2.5f, 2.5f)); buttonPlace.startAnimation(setAnimScale(0.0f, 0.0f)); buttonWith.startAnimation(setAnimScale(0.0f, 0.0f)); buttonCamera.startAnimation(setAnimScale(0.0f, 0.0f)); buttonMusic.startAnimation(setAnimScale(0.0f, 0.0f)); buttonThought.startAnimation(setAnimScale(0.0f, 0.0f)); buttonDelete.startAnimation(setAnimScale(0.0f, 0.0f)); } }); }
/** @Description 初始化界面控件 有点庞大 todo */ private void initView() { // 绑定布局资源(注意放所有资源初始化之前) LayoutInflater.from(this).inflate(R.layout.tt_activity_message, topContentView); // TOP_CONTENT_VIEW setLeftButton(R.drawable.tt_top_back); setLeftText(getResources().getString(R.string.top_left_back)); setRightButton(R.drawable.tt_top_right_group_manager); topLeftBtn.setOnClickListener(this); letTitleTxt.setOnClickListener(this); topRightBtn.setOnClickListener(this); // 列表控件(开源PTR) lvPTR = (PullToRefreshListView) this.findViewById(R.id.message_list); textView_new_msg_tip = (TextView) findViewById(R.id.tt_new_msg_tip); lvPTR .getRefreshableView() .addHeaderView( LayoutInflater.from(this) .inflate(R.layout.tt_messagelist_header, lvPTR.getRefreshableView(), false)); Drawable loadingDrawable = getResources().getDrawable(R.drawable.pull_to_refresh_indicator); final int indicatorWidth = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 29, getResources().getDisplayMetrics()); loadingDrawable.setBounds(new Rect(0, indicatorWidth, 0, indicatorWidth)); lvPTR.getLoadingLayoutProxy().setLoadingDrawable(loadingDrawable); lvPTR.getRefreshableView().setCacheColorHint(Color.WHITE); lvPTR.getRefreshableView().setSelector(new ColorDrawable(Color.WHITE)); lvPTR.getRefreshableView().setOnTouchListener(lvPTROnTouchListener); adapter = new MessageAdapter(this); lvPTR.setAdapter(adapter); lvPTR.setOnRefreshListener(this); lvPTR.setOnScrollListener( new PauseOnScrollListener(ImageLoader.getInstance(), true, true) { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case AbsListView.OnScrollListener.SCROLL_STATE_IDLE: if (view.getLastVisiblePosition() == (view.getCount() - 1)) { textView_new_msg_tip.setVisibility(View.GONE); } break; } } }); textView_new_msg_tip.setOnClickListener(this); // 界面底部输入框布局 sendBtn = (TextView) this.findViewById(R.id.send_message_btn); recordAudioBtn = (Button) this.findViewById(R.id.record_voice_btn); audioInputImg = (ImageView) this.findViewById(R.id.voice_btn); messageEdt = (CustomEditView) this.findViewById(R.id.message_text); RelativeLayout.LayoutParams messageEdtParam = (LayoutParams) messageEdt.getLayoutParams(); messageEdtParam.addRule(RelativeLayout.LEFT_OF, R.id.show_emo_btn); messageEdtParam.addRule(RelativeLayout.RIGHT_OF, R.id.voice_btn); keyboardInputImg = (ImageView) this.findViewById(R.id.show_keyboard_btn); addPhotoBtn = (ImageView) this.findViewById(R.id.show_add_photo_btn); addEmoBtn = (ImageView) this.findViewById(R.id.show_emo_btn); messageEdt.setOnFocusChangeListener(msgEditOnFocusChangeListener); messageEdt.setOnClickListener(this); messageEdt.addTextChangedListener(this); addPhotoBtn.setOnClickListener(this); addEmoBtn.setOnClickListener(this); keyboardInputImg.setOnClickListener(this); audioInputImg.setOnClickListener(this); recordAudioBtn.setOnTouchListener(this); sendBtn.setOnClickListener(this); initSoundVolumeDlg(); // OTHER_PANEL_VIEW addOthersPanelView = findViewById(R.id.add_others_panel); LayoutParams params = (LayoutParams) addOthersPanelView.getLayoutParams(); if (keyboardHeight > 0) { params.height = keyboardHeight; addOthersPanelView.setLayoutParams(params); } View takePhotoBtn = findViewById(R.id.take_photo_btn); View takeCameraBtn = findViewById(R.id.take_camera_btn); takePhotoBtn.setOnClickListener(this); takeCameraBtn.setOnClickListener(this); // EMO_LAYOUT emoLayout = (LinearLayout) findViewById(R.id.emo_layout); LayoutParams paramEmoLayout = (LayoutParams) emoLayout.getLayoutParams(); if (keyboardHeight > 0) { paramEmoLayout.height = keyboardHeight; emoLayout.setLayoutParams(paramEmoLayout); } emoGridView = (EmoGridView) findViewById(R.id.emo_gridview); yayaEmoGridView = (YayaEmoGridView) findViewById(R.id.yaya_emo_gridview); emoRadioGroup = (RadioGroup) findViewById(R.id.emo_tab_group); emoGridView.setOnEmoGridViewItemClick(onEmoGridViewItemClick); emoGridView.setAdapter(); yayaEmoGridView.setOnEmoGridViewItemClick(yayaOnEmoGridViewItemClick); yayaEmoGridView.setAdapter(); emoRadioGroup.setOnCheckedChangeListener(emoOnCheckedChangeListener); // LOADING View view = LayoutInflater.from(MessageActivity.this).inflate(R.layout.tt_progress_ly, null); progressbar = (MGProgressbar) view.findViewById(R.id.tt_progress); LayoutParams pgParms = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); pgParms.bottomMargin = 50; addContentView(view, pgParms); // ROOT_LAYOUT_LISTENER baseRoot.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener); }
public void setLParamHeight(int h) { lpH = h; lparams.height = h; }