Friday, September 19, 2014


First example in Android using L Preview API

Before start to create an example check this this post to create emulator using L Preview OS.

Step 1
Create new project and set the API level as show in below image


When you selecting L Preview API level for minimum required SDK same level will be set in Target SDK.

Looking for L Preview API for Compile with don't worry just select API 20 right now, we'll change it later on once Project is created.

Now just finish the rest of the thing with your requirement and finish wizard to start the project.

First we need to change the compile version as we use version kitkat 20 wear API level for this project instead of this need to apply L Preview. Right click on project and go the Android tab and select the L Preview level API and apply it.



Next thing need to apply Material Theme for your App, see below image as I removed other values folder from my project just keep the default values folder, open the style.xml file and remove current code and  write the new code as below

style.xml

<resources>
  <!-- inherit from the material theme -->
  <style name="AppTheme" parent="android:Theme.Material">
      <!-- Customize your theme here -->
  </style>
</resources>

This will be use the new theme for your Application.

Now change the code in your layout as for me I have created activity_main.xml in my project write the below new code.

<TextView
        android:layout_margin="5dp"
        android:id="@+id/my_textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:elevation="5dp"
        android:text="@string/hello_world"
        android:textColor="#000000" />


android:elevation
The new translationZ property lets you create animations that reflect temporary changes in the elevation of a view. For example, this is useful to respond to touch gestures.

Start your emulator and run this project. This project only run under L Preview  OS.

No comments:

Post a Comment