Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyTabView extends RelativeLayout{
- public MyTabView(Context context) {
- super(context);
- ImageView imageView = new ImageView(context);
- imageView.setImageResource(R.drawable.icon);
- imageView.setId(1);
- //may also want to set a scaleType on the imageView
- LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- params.addRule(RelativeLayout.CENTER_HORIZONTAL);
- imageView.setLayoutParams(params);
- this.addView(imageView);
- TextView textView = new TextView(context);
- textView.setText("some text");
- params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
- params.addRule(RelativeLayout.CENTER_HORIZONTAL);
- params.addRule(RelativeLayout.BELOW, 1);
- textView.setLayoutParams(params);
- this.addView(textView);
- }
- }
Add Comment
Please, Sign In to add comment