M.V.
M.V.

Reputation: 1672

Defining theme in Android APP

I have tried to add in Manifest

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

and in style

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:style/Theme.Holo.Light">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>
</resources>

No matter what I do i always have black action-bar and nothing changes... I want to apply Holo Light theme ...

Any suggestion?

Upvotes: 0

Views: 2067

Answers (2)

Kasirajan M
Kasirajan M

Reputation: 135

create a custom theme.

First, in values add a themes.xml like this:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
    <!-- Any customizations for your app running on pre-3.0 devices here -->
    </style>
</resources> 

Then, create a directory with the name "values-v11" (Android 3.0+ ) in the res directory and put a themes.xml like this

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
    <!-- Any customizations for your app running on 3.0+ devices here -->
    </style>
</resources>

Finally, create a directory with the name "values-v14" (Android 4.0+) in the res directory and create a themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
    <!-- Any customizations for your app running on 4.0+ devices here -->
    </style>
</resources>

manifest.xml

<application
    ...
    android:theme="@style/MyAppTheme">

</application>

OR Create Custom Action Bar

actionbar_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    style="@style/ActionBarCompat" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="15dip"
        android:paddingTop="15dip"
        android:scaleType="center"
        android:textColor="#ffffff"
        android:textSize="20sp"
        android:textStyle="bold"
        android:text="NAME" />

</LinearLayout>

In your layout file. main_activity.xml

   <include layout="@layout/actionbar_layout"/>

in values->styles.xml

<style name="ActionBarCompat">
    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">50dp</item>
    <item name="android:orientation">horizontal</item>
    <item name="android:background">@drawable/actionbar_background</item>
</style>

Upvotes: 2

kai
kai

Reputation: 534

If you want to use the theme in your whole app, try this:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Holo.Light" >

Upvotes: 1

Related Questions