List of usage examples for android.widget ImageView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:org.videolan.vlc.gui.video.MediaInfoFragment.java
private void updateImage() { if (getView() == null) return;//w w w . j a v a 2s . c om ImageView imageView = (ImageView) getView().findViewById(R.id.image); imageView.setImageBitmap(mImage); ViewGroup.LayoutParams lp = imageView.getLayoutParams(); lp.height = mImage.getHeight(); lp.width = mImage.getWidth(); imageView.setLayoutParams(lp); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); mPlayButton.setVisibility(View.VISIBLE); mLengthView.setVisibility(View.VISIBLE); }
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/* w ww. jav a 2 s.co m*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:run.ace.TabBar.java
View getCustomTabView(AppBarButton abb, Context themedContext) { float scaleFactor = Utils.getScaleFactor(themedContext); final int IMAGEHEIGHT = (int) (17 * scaleFactor); final int TEXTSIZE = 12; LinearLayout ll = new LinearLayout(themedContext); LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); llp.gravity = Gravity.CENTER_HORIZONTAL; ll.setLayoutParams(llp);/*from w w w . j a v a 2 s .co m*/ ll.setOrientation(LinearLayout.VERTICAL); if (abb.icon != null) { ImageView iv = new ImageView(themedContext); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, IMAGEHEIGHT); p.gravity = Gravity.CENTER_HORIZONTAL; p.topMargin = (int) (4 * scaleFactor); p.bottomMargin = (int) (3 * scaleFactor); iv.setLayoutParams(p); Bitmap bitmap = Utils.getBitmapAsset(themedContext, abb.icon.toString()); iv.setImageDrawable(new android.graphics.drawable.BitmapDrawable(bitmap)); ll.addView(iv); } TextView tv = new TextView(themedContext); LinearLayout.LayoutParams tvp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); tvp.gravity = Gravity.CENTER_HORIZONTAL; tv.setLayoutParams(tvp); tv.setTypeface(null, Typeface.BOLD); tv.setTextSize(TEXTSIZE); tv.setText(abb.label.toUpperCase()); ll.addView(tv); return ll; }
From source file:com.nike.plusgps.nikeplusgallery.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); dbHelper = new DBHelper(this); // Creates the database dbHelper.deleteAllResponse(); // Clears the JSON response cache dbHelper.deleteAllMedia(); // Clears the JSON images cache // Get memory class of this device, exceeding this amount will throw an // OutOfMemory exception. final int memClass = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass(); // Use 1/8th of the available memory for this memory cache. final int cacheSize = 1024 * 1024 * memClass / 8; mMemoryCache = new LruCache<String, Bitmap>(cacheSize) { @Override//from www. j ava 2 s . co m protected int sizeOf(String key, Bitmap bitmap) { // The cache size will be measured in bytes rather than number of items. return bitmap.getByteCount(); } }; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { setContentView(R.layout.activity_main_port); GridView view = (GridView) findViewById(R.id.gridView); flickrFeedList = new ArrayList<FlickrFeed>(); new JSONParser() .execute("http://api.flickr.com/services/feeds/photos_public.gne?tags=nike&format=json"); adapter = new FlickrFeedAdapter(getApplicationContext(), R.layout.single_elem_port, flickrFeedList, dbHelper, mMemoryCache); view.setAdapter(adapter); } else { setContentView(R.layout.activity_main_land); carouselElement = (LinearLayout) findViewById(R.id.carousel); // Compute width of a carousel item based on screen width and initial item count final DisplayMetrics displayMetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); final int imageWidth = (int) (displayMetrics.widthPixels / INITIAL_ITEMS_COUNT); ImageView imageItem; String imgURL; for (int i = 0; i < flickrFeedList.size(); ++i) { imageItem = new ImageView(this); imgURL = flickrFeedList.get(i).getMedia(); new DownloadImageTask(imageItem).execute(imgURL); imageItem.setLayoutParams(new LinearLayout.LayoutParams(imageWidth, imageWidth)); carouselElement.addView(imageItem); } } }
From source file:baasi.hackathon.sja.TalkActivity.java
/** * ???? ? ?// ww w .j ava 2s. co m * @param resId */ private void addToContainer(int resId) { if (containerLayout != null && containerLayout.getChildCount() <= 4) { ImageView image = new ImageView(getBaseContext()); image.setImageResource(resId); LinearLayout.LayoutParams parms = new LinearLayout.LayoutParams(170, 170); image.setLayoutParams(parms); image.setScaleType(ImageView.ScaleType.CENTER_CROP); PlayAnim(image, this, R.anim.slide_right_in, 0); image.setTag(resId); containerLayout.addView(image); } }
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingPlayView.java
/** * .//from ww w . j a v a2 s . c o m */ public void creatIndex() { //? navLinearLayout.removeAllViews(); mNavLayoutParent.setHorizontalGravity(navHorizontalGravity); navLinearLayout.setGravity(Gravity.CENTER); navLinearLayout.setVisibility(View.VISIBLE); count = mListViews.size(); navLayoutParams.setMargins(5, 5, 5, 5); navLayoutParams.width = 15; navLayoutParams.height = 15; for (int j = 0; j < count; j++) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(navLayoutParams); if (j == 0) { imageView.setImageDrawable(displayDrawable); } else { imageView.setImageDrawable(hideDrawable); } AbViewUtil.scaleView(imageView); navLinearLayout.addView(imageView, j); } }
From source file:com.bangqu.eshow.view.sliding.ESSlidingPlayView.java
/** * .//from www . j a v a2s .c o m */ public void creatIndex() { //? navLinearLayout.removeAllViews(); mNavLayoutParent.setHorizontalGravity(navHorizontalGravity); navLinearLayout.setGravity(Gravity.CENTER); navLinearLayout.setVisibility(View.VISIBLE); count = mListViews.size(); navLayoutParams.setMargins(5, 5, 5, 5); navLayoutParams.width = 15; navLayoutParams.height = 15; for (int j = 0; j < count; j++) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(navLayoutParams); if (j == 0) { imageView.setImageDrawable(displayDrawable); } else { imageView.setImageDrawable(hideDrawable); } ESViewUtil.scaleView(imageView); navLinearLayout.addView(imageView, j); } }
From source file:com.ab.view.sliding.AbSlidingPlayView.java
/** * ./*from w ww . j a va 2 s . com*/ */ public void creatIndex() { //? navLinearLayout.removeAllViews(); mNavLayoutParent.setHorizontalGravity(navHorizontalGravity); navLinearLayout.setGravity(Gravity.CENTER); navLinearLayout.setVisibility(View.VISIBLE); count = mListViews.size(); navLayoutParams.setMargins(5, 5, 5, 5); for (int j = 0; j < count; j++) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(navLayoutParams); if (j == 0) { imageView.setImageBitmap(displayImage); } else { imageView.setImageBitmap(hideImage); } navLinearLayout.addView(imageView, j); } }
From source file:com.ayo.opensource.zlayout.MainPagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { View itemView;/*w ww . j av a 2 s . com*/ Girl girl = mAllGirlList.get(position); if (mAllImageMap.containsKey(position)) { View oldView = mAllImageMap.get(position); Object tag = oldView.getTag(); if (null != tag && tag instanceof Girl) { if (tag.equals(girl)) { itemView = oldView; container.addView(itemView); return itemView; } } container.removeView(oldView); mAllImageMap.remove(position); } ImageView imageView = new ImageView(mContext); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); VanGogh.paper(imageView).paintMiddleImage(girl.getImageUrl(), null, null); //Glide.with(mContext).load(girl.getImageUrl()).into(imageView); imageView.setTag(girl); ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); imageView.setLayoutParams(layoutParams); mAllImageMap.put(position, imageView); itemView = imageView; itemView.setOnClickListener(this); container.addView(itemView); return itemView; }
From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java
public ArrayList<ImageView> DrawSVG(Context context, ImageView orgnlImageView, RelativeLayout rel_anm_lo) { paint.setColor(Color.WHITE);/*from w w w .j av a 2s. c om*/ paint.setStyle(Paint.Style.FILL); LoadSVG.SVGData data = AnimActivity.svg_data; ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); imgViews.add(orgnlImageView); if (data.symbl != null) { ArrayList<String> sprt_ordr = data.svg.ordr; int sym_mbr = 0; Bitmap bitmap; Canvas canvas; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); data.svg.initScl = new float[sprt_nmbr]; float[] initScl = data.svg.initScl; for (int sprt_mbr = 1; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); // e.g., id="g2_0" if (Integer.parseInt(sprt_id.substring(sprt_id.indexOf('_') + 1)) > 0) { // The symbol is already drawn; replicate the view String init_sprt = sprt_id.substring(0, sprt_id.indexOf('_') + 1) + '0'; String svg_ordr = data.svg.svg_ordr; String cnt_str = svg_ordr.substring(0, svg_ordr.indexOf(init_sprt)); ImageView init_vw = imgViews.get(StringUtils.countMatches(cnt_str, ",")); Bitmap initBmp = ((BitmapDrawable) init_vw.getDrawable()).getBitmap(); bitmap = Bitmap.createBitmap(initBmp.getWidth(), initBmp.getHeight(), initBmp.getConfig()); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); } else { // The symbol needs to be drawn; a new view is used bitmap = getCreatBmp(rel_anm_lo); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); // - Set the init values xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); // - Draw the bitmap LoadSVG.symbol crt_sym = data.symbl.get(sym_mbr); ArrayList<LoadSVG.path> pths = crt_sym.pths; int pth_nmbr = pths.size(); // Loop through the paths for (int pth_mbr = 0; pth_mbr < pth_nmbr; pth_mbr += 1) { LoadSVG.path crt_pth = pths.get(pth_mbr); final Path path = new Path(); final Paint paint = new Paint(); /* Debug if (pth_mbr + 1 == pth_nmbr) { String log_str = "Paths: pth_mbr = " + String.valueOf(pth_mbr) + "; color = " + crt_pth.clr; Log.d("DrawSVG", log_str); } */ paint.setColor(Color.parseColor(crt_pth.clr)); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); ld_pth_pnts(crt_pth.pth, path); path.close(); path.setFillType(Path.FillType.EVEN_ODD); canvas.drawPath(path, paint); } canvas.restore(); sym_mbr += 1; } ImageView iv = new ImageView(context); iv.setImageBitmap(bitmap); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); iv.draw(canvas); iv.setLayoutParams(rlp); iv.setBackgroundColor(Color.TRANSPARENT); imgViews.add(iv); } // sprites } // if symbol return imgViews; }