導航:首頁 > 操作系統 > 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樣式相關的資料

熱點內容
人踩什麼解壓 瀏覽:911
php語法檢查命令 瀏覽:330
如何重設伺服器網關 瀏覽:864
世界經濟pdf 瀏覽:108
異或演算法找缺失的數 瀏覽:325
單片機flagt1 瀏覽:485
單片機清理 瀏覽:659
東風景逸空調壓縮機 瀏覽:157
天津程序員炒股 瀏覽:230
pcl源碼目錄 瀏覽:968
python分類數據轉換 瀏覽:109
wordpdf不能復制 瀏覽:961
快捷方式參數命令 瀏覽:111
cmd命令復制粘貼文件 瀏覽:584
ug實體快速修剪的命令是什麼 瀏覽:123
軟體工程對演算法的要求 瀏覽:935
元史pdf 瀏覽:97
如何讓伺服器卡爆不用tnt 瀏覽:801
兵器pdf 瀏覽:925
雲伺服器怎麼限制cpu 瀏覽:166