3

I have created a simple custom TextView. The layout designer however, won't let me preview those custom TextViews, only MockView-Blocks are being rendered.

public class MainTextView : TextView
{
        public Typeface typeface;

        public MainTextView (Context context) : base(context, null)
        {
            InitializeView(context);
        }
     ...
}

Is how my class goes. I would like to preview my custom TextViews, but how can I do that?

Saphire
  • 1,812
  • 1
  • 18
  • 34
  • Which SDK do you target? 24? – Demitrian Jan 17 '17 at 14:15
  • I never saw visual studio can show customer view preview. May be [android studio can](http://stackoverflow.com/questions/34613628/showing-custom-font-or-view-in-preview-section-of-android-studio-xml). – Mike Ma Jan 18 '17 at 05:48

1 Answers1

0

If you are in the layout file, you can use:

<(insert your namespace for MainTextView here).MainTextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Hello world" />

That should work, you just have to put the namespace that your textview is a part of.

I would also like to note that I've had issues with Visual Studio failing to render my views no matter what I do, so in those situations there's not much you can do.