最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Android编程实现简单设置按钮颜色的方法
时间:2017-05-15 编辑:简简单单 来源:一聚教程网
1.工程目录
a.在res目录-新建drawble文件夹放入自定义图片
2.main.xml
代码如下 | 复制代码 |
android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="#000000" android:src="@drawable/sy" /> |
3.类代码
代码如下 | 复制代码 |
packagecom.YANSE; importandroid.app.Activity; importandroid.os.Bundle; importandroid.widget.ImageButton; publicclassYANSEextendsActivity { privateImageButton Image =null; @Override publicvoidonCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Image=(ImageButton)findViewById(R.id.button); } } |
相关文章
- sora软件价格介绍 02-22
- sora官网入口地址一览 02-22
- Sora生成的视频使用教程 02-22
- 《梦幻西游》元宵灯谜线索答案大全2024 02-22
- 《原神》有朋自远方来第一天通关攻略 02-22
- 《苏醒之路》四个结局达成攻略 02-22