List of usage examples for android.widget ImageView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.vonglasow.michael.satstat.ui.RadioSectionFragment.java
private final void addWifiResult(ScanResult result) { // needed to pass a persistent reference to the OnClickListener final ScanResult r = result; android.view.View.OnClickListener clis = new android.view.View.OnClickListener() { @Override//from w ww . ja v a 2 s.co m public void onClick(View v) { onWifiEntryClick(r.BSSID); } }; LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext()); wifiLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); wifiLayout.setOrientation(LinearLayout.HORIZONTAL); wifiLayout.setWeightSum(22); wifiLayout.setMeasureWithLargestChildEnabled(false); ImageView wifiType = new ImageView(wifiAps.getContext()); wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3)); if (WifiCapabilities.isAdhoc(result)) { wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc); } else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) { wifiType.setImageResource(R.drawable.ic_content_wifi_eap); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) { wifiType.setImageResource(R.drawable.ic_content_wifi_psk); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) { wifiType.setImageResource(R.drawable.ic_content_wifi_wep); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) { wifiType.setImageResource(R.drawable.ic_content_wifi_open); } else { wifiType.setImageResource(R.drawable.ic_content_wifi_unknown); } wifiType.setScaleType(ScaleType.CENTER); wifiLayout.addView(wifiType); TableLayout wifiDetails = new TableLayout(wifiAps.getContext()); wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19)); TableRow innerRow1 = new TableRow(wifiAps.getContext()); TextView newMac = new TextView(wifiAps.getContext()); newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14)); newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newMac.setText(result.BSSID); innerRow1.addView(newMac); TextView newCh = new TextView(wifiAps.getContext()); newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newCh.setText(getChannelFromFrequency(result.frequency)); innerRow1.addView(newCh); TextView newLevel = new TextView(wifiAps.getContext()); newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3)); newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newLevel.setText(String.valueOf(result.level)); innerRow1.addView(newLevel); innerRow1.setOnClickListener(clis); wifiDetails.addView(innerRow1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); TableRow innerRow2 = new TableRow(wifiAps.getContext()); TextView newSSID = new TextView(wifiAps.getContext()); newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19)); newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small); newSSID.setText(result.SSID); innerRow2.addView(newSSID); innerRow2.setOnClickListener(clis); wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); wifiLayout.addView(wifiDetails); wifiLayout.setOnClickListener(clis); wifiAps.addView(wifiLayout); }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
/** * Private convenience methods used by this class. *//*from www. j a v a 2s. c o m*/ private void setActiveIndicator(int position) { if (mIndicatorContainer.findViewWithTag(TAG_CIRCLE) == null) { // No indicators yet, let's make some. Only run once per configuration. for (int i = 0; i < getCount(); i++) { ImageView indicator = (ImageView) View.inflate(mContext, R.layout.swipeselector_circle_item, null); if (i == position) { indicator.setImageDrawable(mActiveCircleDrawable); } else { indicator.setImageDrawable(mInActiveCircleDrawable); } indicator.setLayoutParams(mCircleParams); indicator.setTag(TAG_CIRCLE); mIndicatorContainer.addView(indicator); } return; } ImageView previousActiveIndicator = (ImageView) mIndicatorContainer.getChildAt(mCurrentPosition); ImageView nextActiveIndicator = (ImageView) mIndicatorContainer.getChildAt(position); previousActiveIndicator.setImageDrawable(mInActiveCircleDrawable); nextActiveIndicator.setImageDrawable(mActiveCircleDrawable); mCurrentPosition = position; if (mOnItemSelectedListener != null) { mOnItemSelectedListener.onItemSelected(getSelectedItem()); } }
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addImage(final String imgUrl) { final ImageView img = new ImageView(getActivity()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.setMargins(15, 0, 15, 0);/*from w w w . j av a 2s. co m*/ params.gravity = Gravity.CENTER_HORIZONTAL; img.setLayoutParams(params); img.setScaleType(ImageView.ScaleType.CENTER_INSIDE); lay.addView(img); final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false).cacheInMemory(true) .showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(150).build(); ImageLoader.getInstance().displayImage(imgUrl, img, options); img.setClickable(true); img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.img_dialog_layout); ImageLoader.getInstance().displayImage(imgUrl.split("\\?resize=")[0], ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options); dialog.setCancelable(true); dialog.show(); } }); }
From source file:org.alfresco.mobile.android.application.fragments.sync.SyncFragment.java
@Override protected void prepareEmptyView(View ev, ImageView emptyImageView, TextView firstEmptyMessage, TextView secondEmptyMessage) {//from ww w. j a v a2s.c o m emptyImageView.setImageResource(R.drawable.ic_empty_folder_rw); emptyImageView.setLayoutParams(DisplayUtils.resizeLayout(getActivity(), 275, 275)); firstEmptyMessage.setText(R.string.sync_empty_title); secondEmptyMessage.setVisibility(View.VISIBLE); secondEmptyMessage.setText(R.string.sync_empty_description); }
From source file:com.ibm.mil.readyapps.physio.fragments.PainLocationFragment.java
/** * Places a marker on the bodyLayout in the given location. * * @param x x location to place the marker. * @param y y location to place the marker. *//*from w ww . j a v a 2 s. c o m*/ private void placePointer(int x, int y) { y -= getYOffset(); //Log.d("PLACE_POINTER", "Placing pointer at: " + x + ", " + y); Drawable pointer_im = getResources().getDrawable(R.drawable.pointer_3x); pointer_im.setBounds(0, 0, 44, 65); ImageView new_pointer = new ImageView(getActivity()); new_pointer.setImageDrawable(pointer_im); new_pointer.setLayoutParams(setLayoutParams(x, y)); bodyLayout.addView(new_pointer); pointers.add(new_pointer); }
From source file:com.pdftron.pdf.controls.AddPageDialogFragment.java
private void initViewPagerDotLayout() { if ((int) Math.ceil(PageType.values().length / 3.0) < 2) return;//from w ww . ja va 2s.com for (int i = 0; i < (int) Math.ceil(PageType.values().length / 3.0); i++) { ImageView dot = new ImageView(getContext()); LinearLayout.LayoutParams dotParams = new LinearLayout.LayoutParams((int) (8 * mDeviceScale + 0.5f), (int) (8 * mDeviceScale + 0.5f)); int margin = (int) (5 * mDeviceScale + 0.5f); dotParams.setMargins(margin, margin, margin, margin); dot.setLayoutParams(dotParams); dot.setImageDrawable(getResources().getDrawable(R.drawable.viewpager_point)); dot.setEnabled(i == 0 ? true : false); mViewPagerDotLayout.addView(dot); } }
From source file:com.retroteam.studio.retrostudio.EditorLandscape.java
/** * Create all the views associated with a measure. * @param v// www . java 2 s . c o m * @param projectLoad */ private void addMeasure(View v, boolean projectLoad) { int whichtrack = (int) v.getTag(R.id.TAG_ROW); int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN); if (!projectLoad) { theproject.track(whichtrack).addMeasure(); } GridLayout myparent = (GridLayout) v.getParent(); ImageView measure = new ImageView(getApplicationContext()); measure.setImageResource(R.drawable.measure_new_empty); measure.setLayoutParams(new LinearLayout.LayoutParams((int) (displaysize.x / 3.32), LinearLayout.LayoutParams.MATCH_PARENT)); measure.setTag(R.id.TAG_ROW, whichtrack); measure.setTag(R.id.TAG_COLUMN, whichmeasure); measure.setTag(R.bool.TAG_HASNOTES, false); measure.setTag(R.id.TAG_GUISNAP, 0); measure.setTag(R.id.TAG_FILLED_NOTES, new ArrayList<int[]>()); measure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /// int whichtrack = (int) v.getTag(R.id.TAG_ROW); int whichmeasure = (int) v.getTag(R.id.TAG_COLUMN); editMeasure(v); } }); myparent.addView(measure, whichmeasure + 1); v.setTag(R.id.TAG_COLUMN, whichmeasure + 1); }
From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java
private void onMediaSelected(MediaModel media) { View rootView = LayoutInflater.from(HomeFragmentActivity.this) .inflate(R.layout.list_item_selected_thumbnail, null); ImageView thumbnail = (ImageView) rootView.findViewById(R.id.selected_photo); rootView.setTag(media.url);/* w ww .j av a 2 s . co m*/ rootView.setOnClickListener(this); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, getResources().getDisplayMetrics()); thumbnail.setLayoutParams(new FrameLayout.LayoutParams(px, px)); /* if (media.mediaMode == MediaMode.IMAGE) { Picasso.with(this).load(new File(media.url)).resize(px, px) .centerCrop().placeholder(R.drawable.cover_blue) .into(thumbnail); } else { } */ if (media.mediaMode == MediaType.VIDEO) { new VideoLoadAsync(getVideoFragment(), thumbnail, false, px, px) .executeOnExecutor(MediaAsync.THREAD_POOL_EXECUTOR, media.url); } else { ImageLoadAsync loadAsync = new ImageLoadAsync(this, thumbnail, px); loadAsync.executeOnExecutor(MediaAsync.THREAD_POOL_EXECUTOR, media.url); } mSelectedImagesContainer.addView(rootView, 0); //if (mImageSelectedCount >= 1 || mVideoSelectedCount >= 1) { if (mSelectedImagesContainer.getChildCount() > 0) { mSelectedImagesContainer.setVisibility(View.VISIBLE); mSelectedImageEmptyMessage.setVisibility(View.GONE); } }
From source file:com.near.chimerarevo.fragments.PostFragment.java
private void addGallery(final String[] imgUrls) { numGalleries++;/*from w ww . java 2s . c om*/ if (!PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("load_imgs_pref", true) || numGalleries > Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString("gallery_num_pref", "20"))) return; HorizontalScrollView hsv = new HorizontalScrollView(getActivity()); LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_HORIZONTAL; params.setMargins(10, 10, 10, 0); hsv.setLayoutParams(params); LinearLayout container = new LinearLayout(getActivity()); container.setOrientation(LinearLayout.HORIZONTAL); for (int i = 0; i < imgUrls.length; i++) { final ImageView img = new ImageView(getActivity()); LayoutParams imgPar = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); if (i == 0) imgPar.setMargins(5, 10, 0, 10); else imgPar.setMargins(10, 10, 0, 10); img.setLayoutParams(imgPar); img.setScaleType(ImageView.ScaleType.CENTER_INSIDE); container.addView(img); final DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisk(false) .cacheInMemory(true).showImageOnLoading(R.drawable.empty_cr).bitmapConfig(Bitmap.Config.RGB_565) .imageScaleType(ImageScaleType.EXACTLY).delayBeforeLoading(200).build(); ImageLoader.getInstance().displayImage(imgUrls[i], img, options); final int k = i; img.setClickable(true); img.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.img_dialog_layout); ImageLoader.getInstance().displayImage(imgUrls[k].split("\\?resize=")[0], ((TouchImageView) dialog.findViewById(R.id.dialog_image)), options); dialog.setCancelable(true); dialog.show(); } }); } hsv.addView(container); lay.addView(hsv); }