导航:首页 > 操作系统 > android样式

android样式

发布时间:2022-01-29 17:19:38

1. android 如何调用html页面和css样式

一个样式表可以使用CSS的@import?声明被输入。这个声明用于一个CSS文件或内部的STYLE元素:
<STYLE TYPE="text/css" MEDIA="screen, projection"< <!-- @import url(http://www.htmlhelp.com/style.css); @import url(/stylesheets/punk.css); DT { background: yellow; color: black } --< </STYLE<

注意其它的CSS规则应该仍然包括在STYLE元素中,但所有的@import?声明必须放在样式表的开始部分。任意在样式表中指定了的规则,其自身超越在输入样式表中对立的规则。例如上例,即使一个输入的样式表包含DT?{?background:?aqua?},定义项(definition terms)依然会是黄色的背景。
被输入的样式表的顺序对于它们怎样层叠是很重要的。在上述的例子中,如果style.css输入的样式表指定了STRONG元素会显示为红色而punk.css样式表指定了STRONG元素显示为黄色的话,那么后面的规则会获胜,而STRONG元素会显示为黄色。

输入的样式表对于模块性效果很有用处。例如,一个网站可以通过使用了的选择符分类样式表。一个simple.css样式表给出公共的元素像BODY、P、H1和H2。此外,一个extra.css样式表给出较少共通的元素像CODE、BLOCKQUOTE和DFN。一个tables.css样式表可以用于定义变革元素的规则。这三个样式表在需要的时候可以使用@import?声明包括在HTML中。三个样式表也可以通过LINK元素组合。

2. 如何修改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);
}
}

3. 如何自定义android Button样式

在windows7操作系统Android studio中按照如下方法定义button的样式。

1、首先使用Android studio创建一个项目,项目结构如下:

4. android样式和主题的区别

主题和样式有什么不同?
主题:Theme是针对窗体级别的,改变窗体样式。在application和activity标签下使用。
样式:Style是针对窗体元素级别的,改变指定控件或者Layout的样式。在具体控件下使用。
怎么自定义主题和样式
具体步骤:
在res/values目录下新建一个名叫style.xml的文件
对于每一个主题和样式,给<style>元素增加一个全局唯一的名字,和一个可选的父类属性
在<style>元素内部,申明一个或者多个<item>,每一个<item>定义了一个名字属性,并且在元素内部定义了这个风格的值
然后可以在其他XML资源,manifest或应用程序代码中引用这些自定义资源

5. android 如何将activity设置成窗口样式

在activity中添加个属性android:theme="@style/Theme.FloatActivity" 就可以了

6. Android开发如何设置Dialog样式

黑色的这个dialog是系统默认的样式,白色的是android4.0以上自带的一个样式,需要在manifest的application中引用@android:style/Theme.Holo.Light这个样式

7. android button自带样式有哪些

android:attr/textAppearanceMedium"
"?android:attr/textAppearanceSmall"

使用方法为:

java代码:
android:textAppearance="?android:attr/textAppearanceLarge"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAppearance="?android:attr/textAppearanceSmall"

style="?android:attr/textAppearan

8. 简述Android 中样式文件使用步骤

在Eclipse中android程序项目目录结构下的res文件夹新建drawable文件夹,并在drawable文件夹下新建各类的xml样式文件,供layout文件夹下的xml布局文件引用,以满足对程序界面的需求开发。如图1和图2是drawable下xml样式文件的样式类型。

图3、iv1到iv4
其次是信号增强即图片顺序播放的效果,在drawable下新建animation_list_sequence.xml样式文件。

<?xml version="1.0" encoding="utf-8"?><!--
根标签为animation-list;
其中oneshot代表着是否只展示一遍,设置为false会不停的循环播放动画;
其中visible规定drawable的初始可见性,默认为flase;
其中variablePadding若为true则允许drawable的距离在当前选择状态下有所改变(If true, allows the drawable’s padding to change based on the current state that is selected.),默认为false;
根标签下,通过item标签对动画中的每一个图片进行声明;
android:ration 表示展示所用的该图片的时间长度,单位为毫秒;
--><animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true"
android:visible="false"
android:variablePadding="false"
>
<item android:drawable="@drawable/iv1" android:ration="200"></item>
<item android:drawable="@drawable/iv2" android:ration="200"></item>
<item android:drawable="@drawable/iv3" android:ration="200"></item>
<item android:drawable="@drawable/iv4" android:ration="200"></item></animation-list>

再者是信号增强即图片顺序播放的效果,在drawable下新建animation_list_reverse.xml样式文件。

<?xml version="1.0" encoding="utf-8"?><!--
根标签为animation-list;
其中oneshot代表着是否只展示一遍,设置为false会不停的循环播放动画;
其中visible规定drawable的初始可见性,默认为flase;
其中variablePadding若为true则允许drawable的距离在当前选择状态下有所改变(If true, allows the drawable’s padding to change based on the current state that is selected.),默认为false;
根标签下,通过item标签对动画中的每一个图片进行声明;
android:ration 表示展示所用的该图片的时间长度,单位为毫秒;
--><animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true"
android:visible="false"
android:variablePadding="false"
>
<item android:drawable="@drawable/iv4" android:ration="200"></item>
<item android:drawable="@drawable/iv3" android:ration="200"></item>
<item android:drawable="@drawable/iv2" android:ration="200"></item>
<item android:drawable="@drawable/iv1" android:ration="200"></item></animation-list>

然后在layout文件夹下新建xml布局文件activity_animation_list.xml,引用上面写好的drawable文件夹下的xml样式文件。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ImageView android:id="@+id/iv_animation_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/animation_list_sequence" />

<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="sequence"
android:text="顺序显示" />

<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="stop"
android:text="停止动画" />

<Button android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="reverse"
android:text="倒序显示" /></LinearLayout>2122232425262728293031

然后在src包下新建Activity的Java文件AnimationListActivity.java,用于演示操作。

package com.zcz.drawablexmltest;import android.app.Activity;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.view.View;import android.view.Window;import android.widget.ImageView;public class AnimationListActivity extends Activity{
private ImageView mIv;
private AnimationDrawable mAd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_animation_list);
mIv = (ImageView) findViewById(R.id.iv_animation_list);
}

public void sequence(View view){
mIv.setImageResource(R.drawable.animation_list_sequence);
mAd = (AnimationDrawable) mIv.getDrawable();
mAd.start();
} public void stop(View view){
mAd = (AnimationDrawable) mIv.getDrawable();
mAd.stop();
} public void reverse(View view){
mIv.setImageResource(R.drawable.animation_list_reverse);
mAd = (AnimationDrawable) mIv.getDrawable();
mAd.start();
}
}

9. android 如何改变checkbox样式

1、首先res/drawable中定义编写如下样式:
<?xml version="1.0" encoding="utf-8"?>

<item android:drawable="@drawable/check_true" android:state_checked="true"></item>
<item android:drawable="@drawable/check_true" android:state_selected="true"></item>
<item android:drawable="@drawable/check_true" android:state_pressed="true"></item>
<item android:drawable="@drawable/check_false"></item>
</selector>

2、在layout中添加checkbox控件

<CheckBox
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_check"
android:button="@null"
android:checked="true"/>
其中drwable/btn_check为1中顶一个文件名称,另外必须将android:button设置为@null。
@drawable/check_true和@drawable/check_false为checkbox不同状态的图片,可自行设计。

10. android好看的样式

我觉得应该是有很多好看的样式吧,要看你所喜欢的一个样式到底是什么的了,应该是每个人的观点都是不一样的。

阅读全文

与android样式相关的资料

热点内容
php404页面代码 浏览:713
php唯一编号 浏览:597
硬盘文件夹没法打开 浏览:441
访问外网的svn服务器地址 浏览:876
想去自由行有什么好的app 浏览:212
视频监控数据库如何加密 浏览:759
解压直接能用的软件 浏览:709
服务器10ge网口是什么意思 浏览:860
travelboast安卓怎么设置路线 浏览:51
播放解压的图 浏览:228
新建一个名为hux的文件夹 浏览:532
桥水基金加密货币 浏览:196
还有什么好app 浏览:152
微软最惨的源码 浏览:41
上海灵意压缩机 浏览:415
泰拉瑞亚2020最新服务器ip地址 浏览:563
安卓机玩吃鸡什么画质 浏览:874
徒步缓解压力的视频 浏览:239
图像算法口诀 浏览:862
人踩什么解压 浏览:923