Niro56
Niro56

Reputation: 75

Colors and Styles in Android

I am attempting to learn how to make Android apps(on Jellybean 4.1.2), but I have a problem with the style of my "HelloWorld" app. What I'm going for looks like this(the default edit text/button look):

enter image description here

Unfortunately, what I have looks like this:

enter image description here

This is my layout file source code:

<?xml version="1.0" encoding="utf-8"?>
    <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:orientation="horizontal">
         <EditText android:id="@+id/edit_message"
             android:layout_weight="1"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:hint="@string/edit_message" />
         <Button
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:text="@string/button_send" />
    </LinearLayout>

How can I get it to look like that, and why wasn't it like that in the first place?

Thanks in advance,

Niro56

Upvotes: 0

Views: 228

Answers (3)

chitranna
chitranna

Reputation: 1639

It can be done just by changing your theme in Android Manifest. Changing inside the Application applies to the entire application,but you can also change the themes for all the different activities in your application. Ex-

 <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black" >
        <activity
            android:name=".AVST"
            android:label="@string/title_activity_avst" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" /> 
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity

Upvotes: 0

Ahmad
Ahmad

Reputation: 72533

The problem is, that the default android widgets and styles changed a lot from version to version. Especially from 2.3 to 3.0. The new Theme which was announced with HC is called the Holo Theme. Unfortunately you can not use this theme in previous versions(not without 3rd party libraries), therefore default widgets on GB and HC for example look pretty different. If you want to use this theme in previous versions there is a lib called HoloEverywhere.

Besides that you should change your project build target to ICS or JB, then you can see your Layout in Holo Theme(even if you don't use HoloEverywhere): enter image description here

Upvotes: 0

EGHDK
EGHDK

Reputation: 18120

If you will just be targeting JellyBean then the code below should do the job. Just add this to your AndroidManifest.xml. When you have the manifest open, make sure you're looking at the xml code like this:

enter image description here

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

You should know that if you try to use the holo theme on a device that doesn't support it (aka: doesn't understand what Theme.Holo is) then it will most likely crash on those devices.

Upvotes: 1

Related Questions