Android中的颜色和样式
我正在尝试学习如何制作Android应用程序(在Jellybean 4.1.2上),但我的“HelloWorld”应用程序的风格有问题。我想要的是这样的(默认的编辑文本/按钮外观): 不幸的是,我所拥有的是这样的:Android中的颜色和样式,android,android-layout,android-theme,Android,Android Layout,Android Theme,我正在尝试学习如何制作Android应用程序(在Jellybean 4.1.2上),但我的“HelloWorld”应用程序的风格有问题。我想要的是这样的(默认的编辑文本/按钮外观): 不幸的是,我所拥有的是这样的: <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@an
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
这是我的布局文件源代码:
<?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>
我怎么能让它看起来像那样,为什么一开始就不是这样
提前感谢,
Niro56如果您只是针对JellyBean,那么下面的代码应该可以完成这项工作。只需将其添加到您的AndroidManifest.xml中。打开清单后,请确保查看的xml代码如下所示:
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
你应该知道,如果你试图在一台不支持holo主题的设备上使用holo主题(又名:不了解什么是主题.holo),那么它很可能会在这些设备上崩溃。问题是,默认的android小部件和样式在版本之间发生了很大的变化。特别是从2.3到3.0。与HC一起宣布的新主题被称为全息主题。不幸的是,您不能在以前的版本中使用此主题(没有第三方库也不行),因此,例如GB和HC上的默认小部件看起来非常不同。如果您想在以前的版本中使用此主题,有一个名为的库 除此之外,您应该将项目构建目标更改为ICS或JB,然后您可以在Holo主题中看到您的布局(即使您没有在任何地方使用Holo):
只需在Android清单中更改主题即可。应用程序内部的更改适用于整个应用程序,但也可以更改应用程序中所有不同活动的主题。前-
<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
关于最后一点(对于Android新手来说,这听起来可能有点吓人):如果应用程序的最低API级别至少为11(平台3.0+),那么它可以运行的所有设备都将支持holo主题,因为它是从3.0开始内置的。或者,你可以包括类似的内容,而不必担心兼容性(就全息主题而言)。