
Now we need to load the XML layout resource from our activity onCreate() callback method, for that open main activity file MainActivity.java from \java\ path and write the code like as shown below. Once you update the SDK version then “ View Required API Level 17” problem will get solved automatically. Once you open adle( Module: app) file update minSDKVersion to 17 or more and click Sync Now like as shown below. To fix this error we need to update the SDK version of our app for that just double click on adle(Module: app) file in application Gradle Scripts section like as shown below. In case if your app SDK version is less than 17 then TextClock will throw an error like “ View Required API Level 17”. The android TextClock has been introduced in API Level 17 so if we use TextClock in our app then it requires a minimum API Level 17. If you observe above code we created a two TextClock controls, one Button and one TextView control in XML Layout file. Now open an activity_main.xml file from \res\layout path and write the code like as shown below activity_main.xml In case if you are not aware of creating an app in android studio check this article Android Hello World App. It is used to set the padding from left, right, top and bottom.įollowing is the example of defining two TextClock controls, one Button control and one TextView control in RelativeLayout to get the time from TextClock on Button click.Ĭreate a new android application using android studio and give names as TextClockExample. It is used to set the background color for textclock control. It is used to change the style (bold, italic, bolditalic) of text. It is used to specify the size of the text. It is used to change the color of the text.

It is used to specify how to align the text like left, right, center, top, etc. It is used to specify the formatting pattern to show the time in 24 hours mode. It is used to specify the formatting pattern to show the time in 12-hour mode.

It is used to uniquely identify the control The following are some of the commonly used attributes related to TextClock control in android applications. If you observe above code snippet, we used android :format12Hour attribute to set the 12 Hours time format based on our requirements.
