Android之Button
来源:互联网 发布:小说下载软件 编辑:程序博客网 时间:2024/06/15 13:45
1.新建android项目,打开activity_main.xml文件,选择下方Design,如果选中Button,在右侧android设备中添加Button
在Text中可以看到Button的参数设置,可以更改android:text的值修改Button中的显示字符
![](file:///C:/Users/Administrator/AppData/Local/YNote/data/qq879F4416B1E4CB3229A9B96F26996348/c4f9475d59c44c209eaba51cfa55585e/clipboard.png)
<Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textView" android:layout_marginTop="40dp" android:layout_toEndOf="@+id/textView" android:text="@string/btn_text" android:background="@color/colorPrimary"/>
2.也可以在strings.xml文件中添加资源信息
<resources>
<stringname="app_name">MyTest160707</string>
<stringname="btn_text">倔强的赞叹2</string>
</resources>
然后将android:text的值更改为btn_text的赋值
android:text="@string/btn_text"
这时显示的Button的字符就是“倔强的赞叹2”
3.同理可以在colors.xml文件中设置颜色属性,在activity_main.xml文件中使用
<?xml version="1.0"encoding="utf-8"?>
<resources>
<colorname="colorPrimary">#3F51B5</color>
<colorname="colorPrimaryDark">#303F9F</color>
<colorname="colorAccent">#FF4081</color>
</resources>
调用
android:background="@color/colorPrimary"
在Text中可以看到Button的参数设置,可以更改android:text的值修改Button中的显示字符
2.也可以在strings.xml文件中添加资源信息
<resources>
<stringname="app_name">MyTest160707</string>
<stringname="btn_text">倔强的赞叹2</string>
</resources>
然后将android:text的值更改为btn_text的赋值
android:text="@string/btn_text"
这时显示的Button的字符就是“倔强的赞叹2”
3.同理可以在colors.xml文件中设置颜色属性,在activity_main.xml文件中使用
<?xml version="1.0"encoding="utf-8"?>
<resources>
<colorname="colorPrimary">#3F51B5</color>
<colorname="colorPrimaryDark">#303F9F</color>
<colorname="colorAccent">#FF4081</color>
</resources>
调用
android:background="@color/colorPrimary"
1 0
- Android 笔记 之 Button
- Android之Button样式
- android之自定义button
- android之Button
- Android之Button
- Android之Button
- android之创建button
- android之Button
- Android控件之Button
- Android学习之button
- Android控件之Button
- android ui之Button
- Android之Button,ImageButton
- Android控件之Button
- Android之Button
- Android之Button
- Android Button之selector
- Android控件之Button
- Android开发之自定义无背景Dialog的实现
- hibernate入门案例
- Java 四种线程池的用法分析
- 表结构设计
- 二分查找算法
- Android之Button
- Linux学习之CentOS(十三)--CentOS6.4下Mysql数据库的安装与配置
- git常用命令总结
- mybatis入门案例
- javascript继承之一
- 自定义View注意点
- unity4和unity5区别
- 安卓中SQLite数据库操作学习
- ListView setOnItemSelectedListener setOnItemClickListener 区别