public CardboardOverlayEyeView(Context context, AttributeSet attrs) : base(context, attrs) { imageView = new ImageView(context, attrs); imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); imageView.setAdjustViewBounds(true); // Preserve aspect ratio. addView(imageView); textView = new TextView(context, attrs); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14.0f); textView.setTypeface(textView.getTypeface(), Typeface.BOLD); textView.setGravity(Gravity.CENTER); textView.setShadowLayer(3.0f, 0.0f, 0.0f, Color.DKGRAY); addView(textView); }
protected override void onCreate(Bundle arg0) { base.onCreate(arg0); LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); TextView tv = new TextView(this); tv.setText("Hello"); tv.setTextSize(20); layout.addView(tv); tv = new TextView(this); tv.setText("World!"); tv.setTextSize(15); tv.setTextColor(unchecked((int)0xFF00FFFF)); layout.addView(tv); button = new Button(this); button.setText("wtf"); layout.addView(button); button.setOnClickListener(new OnClickListener() { OnClick = (v) => { Console.WriteLine(toString()); button.setText(System.Environment.TickCount.ToString()); } }); /* * Normally in Java, you'd handle the onClickListener with an inner class. * In C# there is no inner class construct. button.setOnClickListener(new OnClickListener() { @Override public void onClick() { } }); */ setContentView(layout); }