快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

android样式,android样式文件放在哪

如何修改Android App的样式风格

android中可以自定义主题和风格。风格,也就是style,我们可以将一些统一的属性拿出来,比方说,长,宽,字体大小,字体颜色等等。可以在res/values目录下新建一个styles.xml的文件,在这个文件里面有resource根节点,在根节点里面添加item项,item项的名字就是属性的名字,item项的值就是属性的值,如下所示:

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的梁河网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

复制代码 代码如下:

?xml version="1.0" encoding="utf-8"?

resources

style name="MyText" parent="@android:style/TextAppearance"

item name="android:textColor"#987456/item

item name="android:textSize"24sp/item

/style

/resources

style中有一个父类属性parent, 这个属性是说明当前的这个style是继承自那个style的,当然这个style的属性值中都包含那个属性中的,你也可以修改继承到的属性的值,好了,style完成了,我们可以测试一下效果了,先写一个布局文件,比如说一个TextView什么的,可以用到这个style的。这里我就写一个EditText吧。下面是布局文件:

复制代码 代码如下:

?xml version="1.0" encoding="utf-8"?

LinearLayout

xmlns:android="http://schemas。android。com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

EditText

android:id="@+id/myEditText"

android:layout_width="match_parent"

android:layout_height="match_parent"

style="@style/MyText"

android:text="测试一下下"/

/LinearLayout

说完了style,下面就说说Theme,Theme跟style差不多,但是Theme是应用在Application或者Activity里面的,而Style是应用在某一个View里面的,还是有区别的,好了,废话不多说,还是看代码吧。下面的是style文件:

复制代码 代码如下:

?xml version="1.0" encoding="utf-8"?

resources

style name="MyText" parent="@android:style/TextAppearance"

item name="android:textColor"#987456/item

item name="android:textSize"24sp/item

/style

style parent="@android:style/Theme" name="CustomTheme"

item name="android:windowNoTitle"true/item

item name="android:windowFrame"@drawable/icon/item

item name="android:windowBackground"?android:windowFrame/item

/style

/resources

style中有一个父类属性parent, 这个属性是说明当前的这个style是继承自那个style的,当然这个style的属性值中都包含那个属性中的,你也可以修改继承到的属性的值,好了,style完成了,我们可以测试一下效果了,先写一个布局文件,比如说一个TextView什么的,可以用到这个style的。这里我就写一个EditText吧。下面是布局文件:

复制代码 代码如下:

?xml version="1.0" encoding="utf-8"?

LinearLayout

xmlns:android="http://schemas。android。com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent"

EditText

android:id="@+id/myEditText"

android:layout_width="match_parent"

android:layout_height="match_parent"

style="@style/MyText"

android:text="测试一下下"/

/LinearLayout

说完了style,下面就说说Theme,Theme跟style差不多,但是Theme是应用在Application或者Activity里面的,而Style是应用在某一个View里面的,还是有区别的,好了,废话不多说,还是看代码吧。下面的是style文件:

复制代码 代码如下:

?xml version="1.0" encoding="utf-8"?

resources

style name="MyText" parent="@android:style/TextAppearance"

item name="android:textColor"#987456/item

item name="android:textSize"24sp/item

/style

style parent="@android:style/Theme" name="CustomTheme"

item name="android:windowNoTitle"true/item

item name="android:windowFrame"@drawable/icon/item

item name="android:windowBackground"?android:windowFrame/item

/style

/resources

可以看到这里写了一个继承自系统默认的Theme的主题,里面有3个属性,这里强调一下第三个属性的值的问题,这里打个问号,然后加前面的一个item的名字表示引用的是那个名字的值,也就是那个名字对应的图片。

然后我们在Manifest.xml里面的Application里面加一个Theme的属性,这个属性对应的就是我们上面写的Theme。

复制代码 代码如下:

application android:icon="@drawable/icon" android:label="@string/app_name"

android:theme="@style/CustomTheme"

activity android:name=".TestStyle"

android:label="@string/app_name"

intent-filter

action android:name="android.intent.action.MAIN" /

category android:name="android.intent.category.LAUNCHER" /

/intent-filter

/activity

上面的代码没有标题栏,背景和fram都是我们设置的图片。当然也可以在代码中设置主题:

复制代码 代码如下:

package com.test.shang;

import android.app.Activity;

import android.os.Bundle;

public class TestStyle extends Activity {

@Override

protected void onCreate (Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setTheme(R.style.CustomTheme);

setContentView(R.layout.test_style);

}

}

[img]

Android系统自带样式Theme总结

本文从网上复制,给自己做笔记的,摘自:

Android系统自带样式(@android:style/) (转)

1 android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"

布局页面最上面 不会显示  android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。

2 android:theme="@style/AppTheme"

布局页面最上面 显示  android:icon="@drawable/ic_launcher"中的值和android:label="@string/app_name"的值。

其他

在AndroidManifest.xml文件的activity中配置

1、android:theme="@android:style/Theme"

默认状态,即如果theme这里不填任何属性的时候,默认为Theme

2、android:theme="@android:style/Theme.NoDisplay"

任何都不显示。比较适用于只是运行了activity,但未显示任何东西

3、android:theme="@android:style/Theme.NoTitleBar“

背景主题的没有标题栏的样式,默认如果没有设置的话,显示黑背景

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

背景主题的没有标题栏且全屏的样式,默认为黑背景

5、android:theme="@android:style/Theme.Black"

默认状态下黑背景

6、android:theme="@android:style/Theme.Black.NoTitleBar"

黑背景主题的没有标题栏的样式

7、android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"

黑背景主题的没有标题栏且全屏的样式

8、android:theme="@android:style/Theme.Light"

默认状态下亮背景,与上述黑背景Theme.Black相反

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

亮背景主题的没有标题栏的样式,与Theme.Black.NoTitleBar相反

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

亮背景主题的没有标题栏且全屏显示的样式,与Theme.Black.NoTitleBa.Fullscreenr相反

11、android:theme="@android:style/Theme.Dialog"

对话框样式 将整个activity变成对话框样式出现

12、android:theme="@android:style/Theme.InputMethod"

Window animations that are applied to input method overlay windows

13、android:theme="@android:style/ Theme.Panel"

删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且此为默认的样式

14、android:theme="@android:style/ Theme.Light.Panel"

删除掉所有多余的窗口装饰,在一个空的矩形框中填充内容,作用范围相当于把dialog中的所有元素全部去掉,只是一个空的矩形框,且默认是light的样式

15、android:theme="@android:style/Theme.Wallpaper"

使用墙纸做主题,默认状态。

16、android:theme="@android:style/ Theme.WallpaperSettings"

使用墙纸做主题,默认是使用将上一个界面调暗之后作为主题

17、android:theme="@android:style/ Theme.Light.WallpaperSettings"

使用墙纸做主题,默认Light状态

18、android:theme="@android:style/Theme.Wallpaper.NoTitleBar"

使用墙纸做主题,且没有标题栏

19、android:theme="@android:style/Theme.Wallpaper.NoTitleBar.Fullscreen"

使用墙纸做主题,且没有标题栏,且全屏显示

20、android:theme="@android:style/Theme.Translucent"

半透明状态下的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。

21、android:theme="@android:style/Theme.Translucent.NoTitleBar"

半透明状态下没有标题栏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。

22、android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"

半透明状态下没有标题栏且全屏的背景,将运行此activity之前的屏幕作为半透明状态作为此activity运行时的样式。

摘自:

Android 中怎么设置全局自定义字体样式

使用stackoverflow软件进行修改。

操作

首先下载自定义字体,拷贝到工程中的assets文件夹下,建个新文件夹也可以。

创建一个继承自Application的类,放上TypeFace的变量。

将系统的serif的字体替换成微软雅黑。

最后自定义的主题。


当前名称:android样式,android样式文件放在哪
当前链接:http://6mz.cn/article/dsopgoj.html

其他资讯