类android.support.v4.view.ViewPager.LayoutParams源码实例Demo

下面列出了怎么用android.support.v4.view.ViewPager.LayoutParams的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: glide-support   文件: GlidePagerFragment.java
@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;
}
 
源代码2 项目: ParallaxViewPagers   文件: MainActivity.java
@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;
  }
 
源代码3 项目: glide-support   文件: GlidePagerFragment.java
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;
}
 
源代码4 项目: open-rmbt   文件: RMBTResultPagerAdapter.java
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();
}
 
 类所在包
 类方法
 同包方法