导航:首页 > 编程语言 > 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代码相关的资料

热点内容
a班练琴app下载不了怎么回事 浏览:349
数控中怎么编程 浏览:409
vm如何安装linux系统 浏览:423
歌手实绩数据在哪里看 浏览:691
代码002 浏览:714
jdk如何编译java文件 浏览:900
修改iptables配置文件 浏览:427
word自动保存指定文件夹 浏览:18
电脑画质不清晰win10 浏览:912
diskgen使用教程 浏览:970
常州数控车编程培训哪里有 浏览:44
如何升级晴明等级 浏览:347
开头是什么文件 浏览:645
linux16进制看elf文件 浏览:663
纸档文件怎么能变成excel档 浏览:481
迅雷下载总出现jsp 浏览:150
创建网页用什么编程语言 浏览:526
考研哪个app好 浏览:30
计算机网络的概念是什么 浏览:625
网络硬盘存储制作 浏览:4

友情链接