List of usage examples for android.widget ImageView setScaleType
public void setScaleType(ScaleType scaleType)
From source file:com.example.imagegallerydemo.photoview.PhotoViewAttacher.java
/** * Sets the ImageView's ScaleType to Matrix. *//*from w w w.j av a 2 s . co m*/ private static void setImageViewScaleTypeMatrix(ImageView imageView) { /** * PhotoView sets its own ScaleType to Matrix, then diverts all calls * setScaleType to this.setScaleType automatically. */ if (null != imageView && !(imageView instanceof IPhotoView)) { if (!ScaleType.MATRIX.equals(imageView.getScaleType())) { imageView.setScaleType(ScaleType.MATRIX); } } }
From source file:hoahong.facebook.messenger.ui.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (Utils.isTablet()) { gridView.setColumnWidth(Utils.dp(60)); } else {/*from w ww . j ava2s. c om*/ gridView.setColumnWidth(Utils.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(Utils.dpf(2.0f)); tabs.setUnderlineHeight(Utils.dpf(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(Utils.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText("No recent"); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utils.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:org.telegram.ui.Views.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {//from w w w . j a v a 2 s . c o m gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable( new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { -14145496, -16777216 })); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
From source file:com.negaheno.ui.Components.EmojiView.java
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); } else {//from ww w. java 2 s.c o m gridView.setColumnWidth(AndroidUtilities.dp(45)); } gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xff999999); adapters.add(localEmojiGridAdapter); } setBackgroundColor(0xff222222); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineHeight(AndroidUtilities.dp(2.0f)); tabs.setUnderlineColor(0x66000000); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dp(61), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dp(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } updateColors(tabs); }
From source file:org.nativescript.widgets.TabLayout.java
/** * Create a default view to be used for tabs. *///from w ww . j a v a2 s . co m protected View createDefaultTabView(Context context, TabItemSpec tabItem) { float density = getResources().getDisplayMetrics().density; int padding = (int) (TAB_VIEW_PADDING_DIPS * density); LinearLayout ll = new LinearLayout(context); ll.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setGravity(Gravity.CENTER); ll.setOrientation(LinearLayout.VERTICAL); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); ll.setBackgroundResource(outValue.resourceId); ImageView imgView = new ImageView(context); imgView.setScaleType(ScaleType.FIT_CENTER); LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); imgLP.gravity = Gravity.CENTER; imgView.setLayoutParams(imgLP); TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setMaxWidth((int) (TEXT_MAX_WIDTH * density)); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setAllCaps(true); textView.setMaxLines(2); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); textView.setPadding(padding, 0, padding, 0); this.setupItem(ll, textView, imgView, tabItem); ll.addView(imgView); ll.addView(textView); return ll; }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossDeviceFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.view_zenoss_device_fragment, container, false); Typeface titlesTypeFace = Typeface.create("sans-serif-light", Typeface.BOLD); deviceTitle = (TextView) rootView.findViewById(R.id.DeviceTitle); deviceTitle.setTypeface(titlesTypeFace); loadAverageGraphView = (ImageView) rootView.findViewById(R.id.loadAverageGraph); CPUGraphView = (ImageView) rootView.findViewById(R.id.CPUGraph); MemoryGraphView = (ImageView) rootView.findViewById(R.id.MemoryGraph); snmpAgent = (TextView) rootView.findViewById(R.id.snmpAgent); snmpAgent.setTypeface(titlesTypeFace); snmpContact = (TextView) rootView.findViewById(R.id.snmpContact); snmpContact.setTypeface(titlesTypeFace); snmpLocation = (TextView) rootView.findViewById(R.id.snmpLocation); snmpLocation.setTypeface(titlesTypeFace); Uptime = (TextView) rootView.findViewById(R.id.uptime); Uptime.setTypeface(titlesTypeFace);//from ww w . jav a 2s . com MemoryRAM = (TextView) rootView.findViewById(R.id.memory_ram); MemoryRAM.setTypeface(titlesTypeFace); MemorySwap = (TextView) rootView.findViewById(R.id.memory_swap); MemorySwap.setTypeface(titlesTypeFace); LastCollected = (TextView) rootView.findViewById(R.id.lastCollected); LastCollected.setTypeface(titlesTypeFace); hsv = (HorizontalScrollView) rootView.findViewById(R.id.horizontalScrollView); try { ImageView deviceRepImg = ((ImageView) rootView.findViewById(R.id.deviceRepImg)); deviceRepImg.setScaleType(ImageView.ScaleType.CENTER_CROP); Random r = new Random(); deviceRepImg.setImageResource(mThumbIds[r.nextInt(mThumbIds.length)]); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossDeviceFragment", "ImageRand", e); } return rootView; }
From source file:com.cylan.jiafeigou.support.photoview.PhotoViewAttacher.java
/** * Set'account the ImageView'account ScaleType to Matrix. *///from w ww . j a v a 2s .co m private static void setImageViewScaleTypeMatrix(ImageView imageView) { /** * PhotoView sets it'account own ScaleType to Matrix, then diverts all calls * setScaleType to this.setScaleType automatically. */ if (null != imageView && !(imageView instanceof IPhotoView)) { if (!ScaleType.MATRIX.equals(imageView.getScaleType())) { imageView.setScaleType(ScaleType.MATRIX); } } }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
/** * Set's the ImageView's ScaleType to Matrix. *///from w w w. j a v a2s . c o m private static void setImageViewScaleTypeMatrix(ImageView imageView) { /** * PhotoView sets it's own ScaleType to Matrix, then diverts all calls * setScaleType to this.setScaleType automatically. */ if (null != imageView && !(imageView instanceof IPhotoView)) { if (!ScaleType.MATRIX.equals(imageView.getScaleType())) { imageView.setScaleType(ScaleType.MATRIX); } } }
From source file:de.uulm.graphicalpasswords.openuyi.UYICreatePasswordActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_uyi_create_password); // Show the Up button in the action bar. setupActionBar();/*from w ww . j a v a2 s . c o m*/ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); length = Integer.parseInt(sharedPref.getString("uyi_length", "10")); originalViews = new ImageView[length]; distortedViews = new ImageView[length]; selectedPictures = new Picture[length]; Bundle bundle = new Bundle(); bundle.putInt("length", length); DialogFragment intro = new IntroDialogFragment(); intro.setArguments(bundle); intro.show(getFragmentManager(), "intro"); vibrator = (Vibrator) this.getSystemService(VIBRATOR_SERVICE); Arrays.fill(selectedPictures, null); gallery = (Gallery) findViewById(R.id.uyi_gallery_originals); gallery.setAdapter(new UYIImageAdapter(this)); gallery.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { ImageView viewOriginal = new ImageView(UYICreatePasswordActivity.this); ImageView viewDistorted = new ImageView(UYICreatePasswordActivity.this); int i = 0; for (; i < selectedPictures.length; i++) { if (i == selectedPictures.length - 1 && selectedPictures[i] != null) { removePicture(i); } if (selectedPictures[i] == null || i == selectedPictures.length - 1) { viewOriginal = originalViews[i]; viewDistorted = distortedViews[i]; selectedPictures[i] = ((UYIImageAdapter) parent.getAdapter()).getPicture(position); vibrator.vibrate(100); ScrollView sv = (ScrollView) findViewById(R.id.uyi_choosepi_scrollview); int height = originalViews[0].getMeasuredHeight(); sv.scrollTo(0, (i * height) - 200); break; } } int originalImageResource = ((UYIImageAdapter) parent.getAdapter()).getImageResource(position); viewOriginal.setImageResource(originalImageResource); viewDistorted.setImageResource( ((UYIImageAdapter) parent.getAdapter()).getDistortedImageResource(position)); ((UYIImageAdapter) parent.getAdapter()).removePicture(position); OnLongClickListener listener = new OnLongClickListener() { @Override public boolean onLongClick(View v) { vibrator.vibrate(200); int viewid = v.getId(); int index = -1; for (int i = 0; i < originalViews.length; i++) { if (originalViews[i].getId() == viewid) { index = i; break; } else if (distortedViews[i].getId() == viewid) { index = i; break; } } Bundle bundle = new Bundle(); bundle.putInt("index", index); DialogFragment dialog = new DeleteImageDialogFragment(); dialog.setArguments(bundle); dialog.show(getFragmentManager(), "delete"); return false; } }; viewOriginal.setOnLongClickListener(listener); viewDistorted.setOnLongClickListener(listener); // Check int count = 0; for (int j = 0; j < selectedPictures.length; j++) { if (selectedPictures[j] != null) { count++; } } if (count == selectedPictures.length) { findViewById(R.id.uyi_save).setClickable(true); findViewById(R.id.uyi_save).setEnabled(true); } } }); table = (TableLayout) findViewById(R.id.uyi_choosepi_tablelayout); LayoutParams params = new LayoutParams(android.widget.TableRow.LayoutParams.WRAP_CONTENT, android.widget.TableRow.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER; for (int i = 0; i < length; i++) { TableRow row = new TableRow(table.getContext()); originalViews[i] = new ImageView(row.getContext()); originalViews[i].setAdjustViewBounds(true); originalViews[i].setScaleType(ScaleType.FIT_XY); originalViews[i].setPadding(3, 3, 3, 3); originalViews[i].setImageResource(R.drawable.oempty); originalViews[i].setId(100 + i); distortedViews[i] = new ImageView(row.getContext()); distortedViews[i].setAdjustViewBounds(true); distortedViews[i].setScaleType(ScaleType.FIT_XY); distortedViews[i].setPadding(3, 3, 3, 3); distortedViews[i].setImageResource(R.drawable.wempty); distortedViews[i].setId(1000 + i); ImageView arrow = new ImageView(row.getContext()); arrow.setAdjustViewBounds(true); arrow.setScaleType(ScaleType.FIT_XY); arrow.setMaxWidth(80); arrow.setPadding(3, 3, 3, 3); arrow.setImageResource(R.drawable.arrow_active); arrow.setLayoutParams(params); row.addView(originalViews[i]); row.addView(arrow); row.addView(distortedViews[i]); table.addView(row); } }
From source file:com.yahala.ui.Views.EmojiViewExtra.java
private void init() { setOrientation(LinearLayout.VERTICAL); loadRecents();//from www .j a v a 2 s. c om setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.parseColor("#FF373737"), Color.parseColor("#FF575757"), Color.parseColor("#FF666666") })); emojiPagerAdapter = new EmojiPagerAdapter(getContext(), EmojiManager.getInstance().categories); pager = new ViewPager(getContext()); pager.setOffscreenPageLimit(5); pager.setAdapter(emojiPagerAdapter); FileLog.e("EmojiManager.emojiGroups", "" + EmojiManager.getInstance().categories.size()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(false); tabs.setMinimumWidth(OSUtilities.dp(50)); tabs.setTabPaddingLeftRight(OSUtilities.dp(10)); tabs.setIndicatorHeight(3); //tabs.setTabBackground(Color.parseColor("#FF3f9fe0")); tabs.setTabBackground(R.drawable.bar_selector_main); tabs.setIndicatorColor(Color.parseColor("#FFffffff")); tabs.setDividerColor(Color.parseColor("#ff222222")); tabs.setUnderlineHeight(2); tabs.setUnderlineColor(Color.parseColor("#ff373737")); //tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new OnClickListener() { public void onClick(View view) { if (EmojiViewExtra.this.listener != null) { EmojiViewExtra.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); /* recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView);*/ addView(localLinearLayout, new LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); if (!EmojiManager.getInstance().categoriesDict.containsKey("recents") || EmojiManager.getInstance().categoriesDict.get("recents").emojis.size() == 0) { pager.setCurrentItem(1); } }