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

热点内容
exosshow哪个app好 浏览:691
clr数据库程序集优点 浏览:919
手机编辑sql文件 浏览:355
装了w8系统d盘文件没了 浏览:509
杀毒软件删除的文件怎么找回 浏览:853
novalct大屏配置文件 浏览:137
iphone磁吸数据线哪个好 浏览:279
终结者远程控制软件账号密码 浏览:53
chttp发送文件路径 浏览:558
网站类论文功能设计模块怎么写 浏览:933
斗鱼伴侣看不到qq游戏 浏览:401
5s怎么看运营商版本 浏览:410
导出选定网格到外部文件 浏览:508
vrmkv文件没有声音 浏览:447
惠普电脑u盘装系统视频教程 浏览:906
ufo文件查看 浏览:399
什么市数据库的安全性 浏览:335
fanucotd数控车床如何编程 浏览:62
苹果开机时白屏黑苹果 浏览:559
有什么网站可以买国外的药 浏览:832

友情链接