/** 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); } }
// 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)); } }); }
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.v4frag); vp = (ViewPager) findViewById(R.id.pager); TextView textView0 = new TextView(this); textView0.setText("page 0"); TextView textView1 = new TextView(this); textView1.setText("page 1"); TextView textView2 = new TextView(this); textView2.setText("page 2"); listViews.add(textView0); listViews.add(textView1); listViews.add(textView2); labels[0] = (TextView) findViewById(R.id.tv11); labels[0].setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { vp.setCurrentItem(0); } }); labels[1] = (TextView) findViewById(R.id.tv12); labels[1].setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { vp.setCurrentItem(1); } }); labels[2] = (TextView) findViewById(R.id.tv13); labels[2].setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { vp.setCurrentItem(2); } }); tv = (TextView) findViewById(R.id.tv); vp.setAdapter(new MyPagerAdapter(listViews)); WIDHT = getWindowManager().getDefaultDisplay().getWidth() / labels.length; LayoutParams lp = (LayoutParams) tv.getLayoutParams(); lp.width = WIDHT; tv.setLayoutParams(lp); vp.setOnPageChangeListener( new OnPageChangeListener() { public void onPageSelected(int position) { System.out.println("onPageSelected"); setSelect(position); TranslateAnimation animation = new TranslateAnimation(left, position * WIDHT, 0, 0); animation.setDuration(200); animation.setFillAfter(true); animation.setFillBefore(true); final int i = position; animation.setAnimationListener( new AnimationListener() { public void onAnimationEnd(Animation animation) { Log.d(tag, "onAnimationEnd"); } public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) { Log.d(tag, "onAnimationStart"); left = i * WIDHT; } }); tv.startAnimation(animation); } public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels) {} public void onPageScrollStateChanged(int state) {} }); setSelect(0); }
// by jmpessoa public void setLParamWidth(int w) { lpW = w; lparams.width = w; }