Delicious Cake
Delicious Cake

Reputation: 111

Simple change of App Theme

I'm trying to change the App Theme into Light.NoTitleBar.Fullscreen (Classic Light).

AndroidManifest.xml: (I was told to add a Blank Activity first and add the Login Activity, then swapping the names Login and Main)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.administrator.helloworld" >
<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme">
    <activity
        android:name=".LoginActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_login"
        android:windowSoftInputMode="adjustResize|stateVisible" >
    </activity>
</application>
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

</manifest>

activity_login.xml: (Login Activity template that I used and modified.)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.administrator.helloworld.LoginActivity"
>

<!-- Login progress -->
<ProgressBar
    android:id="@+id/login_progress"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="470dp"
    android:layout_height="470dp"
    android:layout_marginBottom="8dp"
    android:visibility="gone"/>

<LinearLayout
    android:id="@+id/email_login_form"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:weightSum="1">

    <ImageView
        android:layout_width="350dp"
        android:layout_height="200dp"
        android:id="@+id/imageView"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/syncz"
        android:layout_marginTop="40dp"
        android:layout_marginBottom="90dp" />

    <TextView
        android:layout_width="79dp"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Login:"
        android:id="@+id/textView"
        android:textStyle="bold" />

    <AutoCompleteTextView
        android:id="@+id/email"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/prompt_email"
        android:inputType="textEmailAddress"
        android:maxLines="1"
        android:singleLine="true"
        android:layout_marginTop="16dp"
        android:textStyle="italic"
        android:layout_marginBottom="10dp" />

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Password"
        android:imeActionId="@+id/login"
        android:imeActionLabel="@string/action_sign_in_short"
        android:imeOptions="actionUnspecified"
        android:inputType="textPassword"
        android:maxLines="1"
        android:singleLine="true"
        android:layout_marginBottom="8dp"
        android:textStyle="italic" />

    <Button
        android:id="@+id/email_sign_in_button"
        style="?android:textAppearanceSmall"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_marginTop="16dp"
        android:text="@string/action_sign_in"
        android:layout_weight="0.11"
        android:textSize="25dp" />

</LinearLayout>

</LinearLayout>

activity_main.xml: (Haven't been configured, it's going to be the menu later on.)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">

<TextView
    android:text="@string/hello_world"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

</RelativeLayout>

styles.xml: (No changes)

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
</style>

</resources>

Photo of general frontpage design - Imgur


Final Edit - It turns out that the way to do it was the same command that I had used earlier but back then I got errors while running it. I must have changed something without knowing it, I don't know but the good news are that it's fixed and running.

Upvotes: 1

Views: 3253

Answers (4)

user3173628
user3173628

Reputation: 182

Try to add this code in application tag of androidmanifest file:

android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"

You can also refer Create Project to start from the beginning. After understanding that you can refer Training Lessons.

To make it simple, check this in mainfest file

android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"

check this in styles.xml:

parent="android:Theme.Light.NoTitleBar.Fullscreen"

Upvotes: 2

Syed Raza Mehdi
Syed Raza Mehdi

Reputation: 4117

you can use Light.NoTitleBar.Fullscreen with activities not with application theme, to customize app theme use this and for those activities you don't want the title bar apply it in activity tag not in application tag

1) download zip file

2) import the res files into res folders

and then in you manifest apply the theme like this in application tag :

<application
 ....
 android:theme="@style/Theme.app theme" 
 .....

if you want to open the app with the activity with no title bar do this

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme=“@android:style/Theme.NoTitleBar.Fullscreen” 
        android:screenOrientation="portrait" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Upvotes: 0

user3173628
user3173628

Reputation: 182

Inorder to change the theme into Light.NoTitleBar.Fullscreen you need to include the below in androidmanifest.xml file

 <application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.Light.NoTilteBar.Fullscreen"
   android:uiOptions="splitActionBarWhenNarrow">

You can add more theme in Styles.xml file .For this click res folder->values->styles

sample code to get an idea:

styles.xml :-

<style name="AppTheme" parent="AppBaseTheme">

</style>

Androidmanifest.xml :-

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

So here you can see this line < android:theme="@style/AppTheme" > in androidmanifest file

"@style" this means the style xml file in res folder So In style.xml file you add more theme as your choice

Upvotes: 0

Hirak Chhatbar
Hirak Chhatbar

Reputation: 3181

Okay, so as it seems, you are a beginner and beginners always concern too much about the appearance of the theme as I used to do. Simply follow these steps: 1) Decide what kind of app you want to make (dont bother about UI) 2) Instead of watching every video of whatever tutorial you have choosen, only go through those videos that are helpful for your project. I know poeple are keen to watch everything that they find interesting. but control your emotions and go for whats useful :p. 3) At some stage, you will realize that u know enough of what you should know at that stage 4) You will automatically come across situations where you will be able to create your own theme using .

PS - from my expericience :p

Upvotes: 0

Related Questions