This example shows how you can apply built-in themes in your application.
Algorithm:
1.) Create a new project by File-> New -> Android Project name it BuiltInThemeExample.
2.) Write following into main.xml:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Built-In Dialog Theme" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="using Android's Theme.Dialog" /> </LinearLayout>
3.) Write following into your manifest file:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.builtinthemeexample" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/Theme.Dialog" > <activity android:name="com.example.builtinthemeexample.BuiltInThemeExampleActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
4.) Run for output.
Steps:
1.) Create a project named BuiltInThemeExample and set the information as stated in the image.
Build Target: Android 4.4
Application Name: BuiltInThemeExample
Package Name: com.example.BuiltInThemeExample
Activity Name: BuiltInThemeExampleActivity
2.) Open BuiltInThemeExampleActivity.java file and write following code there:
package com.example.builtinthemeexample; import android.app.Activity; import android.os.Bundle; import android.view.Menu; public class BuiltInThemeExampleActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.using_custom_theme, menu); return true; } }
3.) Compile and build the project.
Output
Top 10 Android App Development Trends | 2020 Guide
The 9 Best Programming Languages To Learn In 2020
10 Best Programming Languages to Learn in 2019 (for Job & Future)
9 Popular Cross-Platform Tools for App Development in 2019
10 Reasons to Learn Python Programming Language in 2019
23 best smartphone tips and tricks to impress your friends
20 Best iOS App Development Tutorials and Online Learning Resources
Top 15 Best Android Apps For C Programming | 2018 Exclusive