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

热点内容
玩火的女孩有几个版本 浏览:113
tvshowtracker安卓版 浏览:983
App数据分析应该从哪些纬度 浏览:17
到底要不要升级ios92 浏览:875
cad2014安装包安装文件在哪里 浏览:63
电信密码无法登录 浏览:820
cad的打印到文件怎么设置 浏览:902
智行app铂金会员怎么还有期限 浏览:581
win10用子文件夹改名 浏览:234
ae钢笔工具在哪里 浏览:460
gn105数据线插哪里 浏览:916
破锁屏密码方法 浏览:835
股票数据放哪里 浏览:576
m格式库文件 浏览:279
天际通数据服务怎么开票 浏览:430
写小说发哪个网站比较好 浏览:244
小米电视3蓝牙文件路径 浏览:111
shell读取文件值 浏览:909
文件夹路径栏消失 浏览:795
律师哪些业务不能代替大数据 浏览:952

友情链接