List of usage examples for android.widget ImageView setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:galilei.kelimekavanozu.view.ImageAdapter.java
@Override public Object instantiateItem(ViewGroup container, final int position) { if (context.get() != null) { final int drawableId = theme.getImageList().get(position + 1); final ImageView view = new ImageView(context.get()); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setContentDescription(context.get().getResources().getString(R.string.content_desc_poempic)); view.setScaleType(ImageView.ScaleType.CENTER_CROP); view.setAdjustViewBounds(true);//from w w w .j a va 2 s . com view.setTag(drawableId); container.addView(view, 0); view.post(new Runnable() { @Override public void run() { ImageLoader.getImageLoader().load(drawableId, view); } }); return view; } return null; }
From source file:org.uis.luu.PicActivity.java
private ImageView createPager(String url) { LinearLayout.LayoutParams dotParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); ImageView imageView = new ImageView(this); imageView.setLayoutParams(dotParams); imageView.setTag(url);//from w w w. j a v a 2 s. c om imageView.setImageResource(R.mipmap.ic_launcher); //imageView.setImageBitmap(null); return imageView; }
From source file:com.manning.androidhacks.hack028.adapter.ImageAdapter.java
public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds[position]); imageView.setLayoutParams(new Gallery.LayoutParams(150, 100)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; }
From source file:com.manning.androidhacks.hack008.MainActivity.java
private ImageView createNewView() { ImageView ret = new ImageView(this); ret.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); ret.setScaleType(ScaleType.FIT_XY);/*www . j a va 2 s .c o m*/ ret.setImageResource(PHOTOS[mIndex]); mIndex = (mIndex + 1 < PHOTOS.length) ? mIndex + 1 : 0; return ret; }
From source file:com.pertamina.tbbm.rewulu.ecodriving.ContentsActivity.java
private void initPanel() { // TODO Auto-generated method stub imgs = new ArrayList<>(); panel.removeAllViews();/* w w w. j a va 2 s. co m*/ for (int w = 0; w < pageSize; w++) { ImageView img = new ImageView(getApplicationContext()); img.setLayoutParams(params); if (0 == w) img.setImageResource(R.drawable.panel_indicator_full); else img.setImageResource(R.drawable.panel_indicator); img.setVisibility(View.VISIBLE); img.setOnClickListener(this); panel.addView(img); imgs.add(img); } }
From source file:com.bruce.study.demo.studydata.viewpage.ViewPagerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); LayoutInflater inflater = getLayoutInflater(); pageViews = new ArrayList<>(5); pageViews.add(inflater.inflate(R.layout.viewpager_item_01, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_02, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_03, null)); pageViews.add(inflater.inflate(R.layout.viewpager_item_04, null)); imageViews = new ImageView[pageViews.size()]; ViewGroup main = (ViewGroup) inflater.inflate(R.layout.viewpager_activity, null); ViewGroup group = (ViewGroup) main.findViewById(R.id.ll_viewgroup); ViewPager viewPager = (ViewPager) main.findViewById(R.id.vp_guide); for (int i = 0; i < pageViews.size(); i++) { ImageView imageView = new ImageView(ViewPagerActivity.this); imageView.setLayoutParams(new ViewGroup.LayoutParams(20, 20)); imageView.setPadding(20, 0, 20, 0); imageViews[i] = imageView;// www .j a v a 2 s. co m if (i == 0) { imageViews[i].setBackgroundResource(R.drawable.viewpager_indicator_focused); } else { imageViews[i].setBackgroundResource(R.drawable.viewpage_indicator); } group.addView(imageViews[i]); } setContentView(main); viewPager.setAdapter(new MyViewPagerAdapter()); viewPager.setOnPageChangeListener(new PageChangeListener()); }
From source file:com.chillax.viewpagerindicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();/* w w w . j a va2s. c o m*/ IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); int padding = ScreenUtil.dp2px(context, 10); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext()); view.setLayoutParams( new ViewGroup.LayoutParams(ScreenUtil.dp2px(context, 35), ScreenUtil.dp2px(context, 35))); view.setPadding(padding, padding, padding, padding); view.setScaleType(ImageView.ScaleType.FIT_XY); view.setImageResource(R.drawable.leader_icon); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.pixate.freestyle.fragment.GridViewFragment.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub /** ImageView for each grid view item */ ImageView imageView; if (convertView == null) { imageView = new ImageView(mContext); imageView.setLayoutParams(new GridView.LayoutParams(mWidth, mHeight)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); } else {// ww w.j av a 2 s . c o m imageView = (ImageView) convertView; } imageView.setBackgroundResource(R.drawable.grid_item_background); return imageView; }
From source file:com.dldzkj.app.renxing.SplashActivity.java
private void initView() { vp = (ViewPager) findViewById(R.id.viewPager); ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup); //?ID/*from w w w . j a v a2 s .co m*/ imgIdArray = new int[] { R.drawable.w1, R.drawable.w2, R.drawable.w3 }; tips = new ImageView[imgIdArray.length]; for (int i = 0; i < tips.length; i++) { ImageView imageView = new ImageView(this); imageView.setLayoutParams(new ViewGroup.LayoutParams(10, 10)); tips[i] = imageView; if (i == 0) { tips[i].setBackgroundResource(R.drawable.dot_focus); } else { tips[i].setBackgroundResource(R.drawable.dot_blur); } LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); layoutParams.leftMargin = 15; layoutParams.rightMargin = 15; layoutParams.bottomMargin = 20; group.addView(imageView, layoutParams); } // mImageViews = new ImageView[imgIdArray.length]; for (int i = 0; i < mImageViews.length; i++) { ImageView imageView = new ImageView(this); mImageViews[i] = imageView; imageView.setBackgroundResource(imgIdArray[i]); } mImageViews[mImageViews.length - 1].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(SplashActivity.this, EnterActivity.class)); finish(); } }); //Adapter vp.setAdapter(new MyAdapter()); //?? vp.setOnPageChangeListener(this); //ViewPager, 100?? vp.setCurrentItem(0); }
From source file:com.flan.stock.fragment.FragmentNewsYw.java
/** * ???/* w w w.j a va2s .c o m*/ */ private void getTouTiaoData() { LayoutParams para = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); ImageView img1 = new ImageView(context); img1.setBackgroundResource(R.drawable.img_ipo); img1.setLayoutParams(para); ImageView img2 = new ImageView(context); img2.setBackgroundColor(Color.BLUE); img2.setLayoutParams(para); toutiaoList = new ArrayList<>(); toutiaoList.add(img1); toutiaoList.add(img2); }