展会信息港展会大全

Android入门之【按钮颜色设置】
来源:互联网   发布日期:2016-01-14 12:24:06   浏览:1451次  

导读:1.工程目录a.在res目录-新建drawble文件夹放入自定义图片2.main.xml?xml version=1.0 encoding=utf-8?LinearLayout xmlns:android=http://schemas.android.com/apk/res/androidandroid:orientation=......

1.工程目录

a.在res目录-新建drawble文件夹放入自定义图片

2.main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

>

<TextView

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:text="@string/hello"

/>

<ImageButton

android:id="@+id/button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#000000"

android:src="@drawable/sy"

/>

</LinearLayout>

3.类代码

package com.YANSE;

import android.app.Activity;

import android.os.Bundle;

import android.widget.ImageButton;

public class YANSE extends Activity {

private ImageButton Image =null;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

Image=(ImageButton)findViewById(R.id.button);

}

}

赞助本站

人工智能实验室

相关热词: 按钮颜色

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港