導航:首頁 > 編程語言 > androidstyle代碼

androidstyle代碼

發布時間:2023-08-18 04:38:32

1. android 可以在程序代碼中設置style嗎

如果你是給textView的話,可以

textView.setTextAppearance(this, R.style.MyStyle);

其它的話就不行了。

2. android怎樣寫style

<style name="button_style">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginRight">20dp</item>
<item name="android:background">@drawable/button_click</item>
</style>

在res/values/styles 下邊 類似這樣寫 就可以 調用的話 style="@style/button_style"
記得 已經在 style中寫的東西 不要在button 下出現。不然會報錯誤


<Button
android:id="@+id/addLessonBtn"
style="@style/button_style"
android:text="@string/add_course_add" />

3. android中怎麼創建style

自定義樣式方法,可以直接通過定義xml文件來實現不同的樣式:
只需要修改button_style文件,同樣三種狀態分開定義:
Xml代碼
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape>
<gradient android:startColor="#0d76e1" android:endColor="#0d76e1"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item android:state_focused="true">
<shape>
<gradient android:startColor="#ffc2b7" android:endColor="#ffc2b7"
android:angle="270" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="2dp" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>

<item>
<shape>
<gradient android:startColor="#000000" android:endColor="#ffffff"
android:angle="180" />
<stroke android:width="1dip" android:color="#f403c9" />
<corners android:radius="5dip" />
<padding android:left="10dp" android:top="10dp"
android:right="10dp" android:bottom="10dp" />
</shape>
</item>
</selector>

gradient 主體漸變 startColor開始顏色,endColor結束顏色 ,angle開始漸變的角度(值只能為90的倍數,0時為左到右漸變,90時為下到上漸變,依次逆時針類推)
stroke 邊框 width 邊框寬度,color 邊框顏色
corners 圓角 radius 半徑,0為直角
padding text值的相對位置

閱讀全文

與androidstyle代碼相關的資料

熱點內容
來拿錢app怎麼樣 瀏覽:708
數控編程的g70是什麼意思 瀏覽:728
兩個插網線怎麼傳數據 瀏覽:213
外圓循環加工如何編程 瀏覽:272
資料庫圖標是個小象是哪個資料庫 瀏覽:278
maxthon文件夾 瀏覽:954
如何編程對萬千百十個數字的篩選 瀏覽:335
apache配置文件詳解 瀏覽:822
word文件後面出現sjz3 瀏覽:794
簡單照相機安卓版 瀏覽:999
美國恐怖故事在哪個app 瀏覽:532
linux共享文件拒絕訪問 瀏覽:26
推特app的語言設置在哪裡 瀏覽:960
PDF文件上傳網路後變成亂碼 瀏覽:222
編程時在什麼情況下有include 瀏覽:849
extjs復制對象 瀏覽:84
lumion7燈光教程 瀏覽:300
如何設計word背景 瀏覽:669
wcf怎麼接受post資料庫 瀏覽:243
會計借貸賬目表怎麼看數據 瀏覽:728

友情鏈接