@Override public @Nullable View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewPager view = new ViewPager(getActivity()); // container.getContext() results in white on white text view.setId(android.R.id.list); view.setLayoutParams(new MarginLayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); PagerTitleStrip title = new PagerTabStrip(view.getContext()); ViewPager.LayoutParams params = new ViewPager.LayoutParams(); params.width = LayoutParams.MATCH_PARENT; params.height = LayoutParams.WRAP_CONTENT; params.gravity = Gravity.TOP; title.setLayoutParams(params); view.addView(title); return view; }
/** * popwd显示 分享 */ public static PopupWindow showShareByWeixin(final Context ctx, View parent, OnClickListener l) { LayoutInflater inflater = LayoutInflater.from(ctx); View view = inflater.inflate(R.layout.share_popwed_show, null); final PopupWindow sharePopwd = new PopupWindow(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); view.findViewById(R.id.sendfrient).setOnClickListener(l); view.findViewById(R.id.sharefriend).setOnClickListener(l); view.findViewById(R.id.share_popwd).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { sharePopwd.dismiss(); } }); sharePopwd.setFocusable(true); sharePopwd.setOutsideTouchable(true); sharePopwd.setBackgroundDrawable(new BitmapDrawable()); // sharePopwd.showAtLocation(parent, Gravity.CENTER, 0, 0); return sharePopwd; }
@Override public Object instantiateItem(final ViewGroup container,final int position) { TextView textView=new TextView(MainActivity.this); textView.setText("item"+position); textView.setBackgroundColor(colors[position]); textView.setGravity(Gravity.CENTER); final LayoutParams params=new LayoutParams(); params.height=LayoutParams.MATCH_PARENT; params.width=LayoutParams.MATCH_PARENT; params.gravity=Gravity.CENTER; textView.setLayoutParams(params); textView.setTextColor(0xff000000); container.addView(textView); return textView; }
@Override public Object instantiateItem(ViewGroup container, final int position) { ImageView iamgeView = new ImageView(activity); iamgeView.setPadding(Util.dip2px(10, activity), Util.dip2px(10, activity), Util.dip2px(10, activity), Util.dip2px(10, activity)); int bg = Color.rgb((int) Math.floor(Math.random() * 128) + 64, (int) Math.floor(Math.random() * 128) + 64, (int) Math.floor(Math.random() * 128) + 64); iamgeView.setBackgroundColor(bg); iamgeView.setImageResource(Constant.nature_images[position]); container.addView(iamgeView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); jazzPager.setObjectForPosition(iamgeView, position); return iamgeView; }
public static void expand(final View v) { v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final int targtetHeight = v.getMeasuredHeight(); v.getLayoutParams().height = 0; v.setVisibility(View.VISIBLE); Animation a = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT : (int)(targtetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; } }; // 1dp/ms a.setDuration(((int) (targtetHeight / v.getContext().getResources().getDisplayMetrics().density))*2); v.startAnimation(a); }
public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(baseActivity); container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); String mImagePath = mImageUrls.get(position); if (isNetworkImg(mImagePath)) { DisplayImageOptions options = new DisplayImageOptions.Builder().imageScaleType(ImageScaleType.EXACTLY_STRETCHED).showStubImage(R.drawable.ic_default_image).showImageForEmptyUri(R.drawable.ic_default_image).bitmapConfig(Config.RGB_565).build(); mImageLoader.displayImage(mImagePath, photoView, options); } else { photoView.setImageBitmap(BitmapUtils.getBitmap(mImagePath, baseActivity.getResources().getDisplayMetrics().widthPixels, baseActivity.getResources().getDisplayMetrics().heightPixels)); } return photoView; }
@Override public void onCreate(final Bundle saved) { super.onCreate(saved); map_ = new CycleMapView(this, this.getClass().getName()); map_.overlayPushBottom(new RouteOverlay(this)); map_.overlayPushTop(new LockScreenOnOverlay(this, map_)); map_.overlayPushTop(new LiveRideOverlay(this, map_)); map_.lockOnLocation(); map_.hideLocationButton(); final RelativeLayout rl = new RelativeLayout(this); rl.addView(map_, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); setContentView(rl); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { //Create the AdView fragment container layout View v = inflater.inflate(R.layout.fragment_ad, container, false); //Generate the AdView and configure it mAdView = new AdView(v.getContext()); mAdView.setVisibility(View.GONE); RelativeLayout.LayoutParams mAdViewLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); mAdView.setLayoutParams(mAdViewLayout); //...set the Ads info mAdView.setAdSize(adSize); mAdView.setAdUnitId(adUnitId); //Add the AdView to the fragment container layout :) ((RelativeLayout)v).addView(mAdView); return v; }
public void addResultListItem(String title, String value, LinearLayout netLayout) { final float scale = activity.getResources().getDisplayMetrics().density; final int leftRightItem = Helperfunctions.dpToPx(5, scale); final int topBottomItem = Helperfunctions.dpToPx(5, scale); final int leftRightDiv = Helperfunctions.dpToPx(0, scale); final int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); final int topBottomImg = Helperfunctions.dpToPx(1, scale); final LinearLayout netItemLayout = new LinearLayout(activity); netItemLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem); netItemLayout.setGravity(Gravity.CENTER_VERTICAL); final TextView itemTitle = new TextView(activity, null, R.style.listResultItemTitle); itemTitle.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.4f)); itemTitle.setWidth(0); itemTitle.setGravity(Gravity.LEFT); itemTitle.setText(title); netItemLayout.addView(itemTitle); final ImageView itemClassification = new ImageView(activity); itemClassification.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 0.1f)); itemClassification.setPadding(0, topBottomImg, 0, topBottomImg); itemClassification.setImageDrawable(activity.getResources().getDrawable( R.drawable.traffic_lights_none)); netItemLayout.addView(itemClassification); final TextView itemValue = new TextView(activity, null, R.style.listResultItemValue); itemValue.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 0.5f)); itemValue.setWidth(0); itemValue.setGravity(Gravity.LEFT); itemValue.setText(value); netItemLayout.addView(itemValue); netLayout.addView(netItemLayout); final View divider = new View(activity); divider.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); netLayout.addView(divider); netLayout.invalidate(); }
@Override public View getView(int position, View convertView, ViewGroup parent) { // if (false) { // if (this.accFileCallback == null) { // return null; // } ACCFile accFile = this.imageData.getAccFiles().get(position); ImageView imageView = !this.isBig ? new ImageView(this.context) : new AutoImageView(this.context, position == 0, position == this.getCount() - 1, this.onSingleTapListener); Bitmap bitmap = this.bitmapProviderManager.getBitmap(accFile); // if (bitmap == null || bitmap.isRecycled()) { // bitmap = BitmapManager.getInstance(context).getBlankBitmap(); // } // LogUtil.systemOut("bitmap == null:"); // LogUtil.systemOut(bitmap == null); // if (true) { if (this.isBig) { imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); } // this.isBig ? // :autoImageView.setScaleType(ImageView.ScaleType.FIT_CENTER); imageView.setLayoutParams(new Gallery.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // imageView.setBackgroundResource(R.drawable.login_input); // } // System.out.println(position); imageView.setImageBitmap(bitmap); if (this.isBig && accFile.getProgress() != null) { ((AutoImageView) imageView).setProgress(accFile.getProgress()); } // } return imageView; }
@Override public View instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(container.getContext()); WeboApplication.getImageLoader().displayImage( Utils.getMiddlePicURL(mImgesURLList.get(position)), photoView, Configure.getFullScreenImageDisplayImageOptions()); // Now just add PhotoView to ViewPager and return it container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return photoView; }
@Override /** * Gets called on start of app. Checks availability of SD card and initiates GUI objects. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //shows the app, even if screen lock is active this.getWindow().addFlags(android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // check for sd card if (!SDCardHandler.isMounted()) { if (SDCardHandler.isRemoved()) { exit("Please insert a SD card"); } else if (SDCardHandler.isShared()) { exit("Please stop USB mass storage mode"); } else { exit("SD card error!"); } } else { try { SDCardHandler.mkDir(DIRECTORY); } catch (IOException e) { exit("No write access to SD card"); } setContentView(R.layout.activity_artifact_extract); browserHCheck = (CheckBox) findViewById(R.id.browserHCheck); browserSCheck = (CheckBox) findViewById(R.id.browserSCheck); calendarCheck = (CheckBox) findViewById(R.id.calendarCheck); callCheck = (CheckBox) findViewById(R.id.callCheck); contactCheck = (CheckBox) findViewById(R.id.contactCheck); mmsCheck = (CheckBox) findViewById(R.id.mmsCheck); smsCheck = (CheckBox) findViewById(R.id.smsCheck); selectAll(null); } }
protected static ImageView createView(ViewGroup parent) { ImageView view = new ImageView(parent.getContext()); view.setId(R.id.image); view.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); return view; }
private void init() { LinearLayout view = new LinearLayout(context); view.setOrientation(LinearLayout.VERTICAL); view.setGravity(Gravity.CENTER_HORIZONTAL); view.setBackgroundColor(Color.rgb(224, 224, 224)); view.setPadding(1, 1, 1, 1); listView = new ListView(context); adapter = new PopAdapter(); listView.setAdapter(adapter); listView.setCacheColorHint(0x00000000); listView.setDivider(new ColorDrawable(0xe0e0e0)); listView.setDividerHeight(1); if (this.config != null && this.config.getBackground_resId() != 0) { listView.setBackgroundResource(this.config.getBackground_resId()); } else { listView.setBackgroundColor(Color.rgb(224, 224, 224)); } LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); view.addView(listView, layoutParams); if (this.config != null && this.config.getWidth() > 0) { popupWindow = new PopupWindow(view, this.config.getWidth(), LayoutParams.WRAP_CONTENT); } else { // 为了自适应长度添加 TextView text = new TextView(context); text.setHeight(0); text.setText("图片的空" + getMostItemText()); text.setTextSize(16); text.setPadding(5, 5, 5, 5); view.addView(text, layoutParams1); popupWindow = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); } if (dismissListener != null) { popupWindow.setOnDismissListener(dismissListener); } // 这个是为了点击“返回Back”也能使其消失,并且并不会影响你的背景(很神奇的) popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // 使其聚集 popupWindow.setFocusable(true); // 设置允许在外点击消失 popupWindow.setOutsideTouchable(true); // 刷新状态 popupWindow.update(); popupWindow.setTouchInterceptor(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { popupWindow.dismiss(); return true; } return false; } }); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // 获取该行的数据 PopMenuItem popMenuItem = (PopMenuItem) listView.getAdapter() .getItem(arg2); if (popMenuItem.listener != null) { popMenuItem.listener.onItemClick(); dismiss(); } } }); }
public LinearLayout.LayoutParams createButtonLayoutParams() { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); return params; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.imgView = (ImageView) findViewById(R.id.imageView1); containerLayoutFrame = (LinearLayout) findViewById(R.id.layout); filtersInt = new int[NUMBERS_OF_FILTERS]; imgFilters = new ImageView[filtersInt.length]; lyparams.height = LayoutParams.MATCH_PARENT; lyparams.width = LayoutParams.WRAP_CONTENT; onClickListenerImagesFilter=new OnClicListenerImagesFilter(); filtersInt[0]=BitmapFilter.GRAY_STYLE; filtersInt[1]=BitmapFilter.BLOCK_STYLE; filtersInt[2]=BitmapFilter.BLUR_STYLE; filtersInt[3]=BitmapFilter.GAUSSIAN_BLUR_STYLE; filtersInt[4]=BitmapFilter.HDR_STYLE; filtersInt[5]=BitmapFilter.INVERT_STYLE; filtersInt[6]=BitmapFilter.LIGHT_STYLE; filtersInt[7]=BitmapFilter.LOMO_STYLE; filtersInt[8]=BitmapFilter.NEON_STYLE; filtersInt[9]=BitmapFilter.OIL_STYLE; filtersInt[10]=BitmapFilter.OLD_STYLE; filtersInt[11]=BitmapFilter.PIXELATE_STYLE; filtersInt[12]=BitmapFilter.RELIEF_STYLE; filtersInt[13]=BitmapFilter.SHARPEN_STYLE; filtersInt[14]=BitmapFilter.SKETCH_STYLE; filtersInt[15]=BitmapFilter.SOFT_GLOW_STYLE; filtersInt[16]=BitmapFilter.TOTAL_FILTER_NUM; filtersInt[17]=BitmapFilter.TV_STYLE; // we convert the image on imgView to a bitmap abmp = (BitmapDrawable) imgView.getDrawable(); bmp = abmp.getBitmap(); originalImageSacled=bmp; myBitmap=bmp; sacleMainImage(); loadFilters(); }