- 浏览: 197091 次
- 性别:
- 来自: 湖南
文章分类
最新评论
Android 基础UI编程
专业相框设计
ImageView 的堆叠应用
① 新建工程
② 准备三张png 图片
left.png right.png photo.png
③ 修改main.xml 布局,添加UI 元素
④ 修改mainActivity.java
ImageButton 的堆叠应用
① 新建项目
② 准备三张png 图片
left.png right.png photo.png
③ 修改main.xml 布局,添加UI 元素
④ 修改mainActivity.java
设置成堆叠
专业相框设计
ImageView 的堆叠应用
① 新建工程
② 准备三张png 图片
left.png right.png photo.png
③ 修改main.xml 布局,添加UI 元素
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout android:id="@+id/widget34" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" ><!--创建第一个ImageView (第二层图片)--> <ImageView android:id="@+id/myImageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="36px" /> <!--创建第二个ImageView (第一层图片)--> <ImageView android:id="@+id/myImageView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="36px" /> <!--创建第一个Button --> <Button android:id="@+id/myButton1" android:layout_width="105px" android:layout_height="66px" android:text="pic1" android:layout_x="9px" android:layout_y="356px" /> <!--创建第二个Button --> <Button android:id="@+id/myButton2" android:layout_width="105px" android:layout_height="66px" android:text="pic2" android:layout_x="179px" android:layout_y="356px" /> </AbsoluteLayout>
④ 修改mainActivity.java
package zyf.Ex_Ctrl_7; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class Ex_Ctrl_7 extends Activity { /** Called when the activity is first created. */ /* 声明Button、ImageView 对象*/ private ImageView mImageView01; private ImageView mImageView02; private Button mButton01; private Button mButton02; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* 取得Button、ImageView 对象*/ mImageView01 = (ImageView) findViewById(R.id.myImageView1); mImageView02 = (ImageView) findViewById(R.id.myImageView2); mButton01 = (Button) findViewById(R.id.myButton1); mButton02 = (Button) findViewById(R.id.myButton2); /* 设置ImageView 背景图*/ mImageView01.setImageDrawable(getResources().getDrawable( R.drawable.right)); mImageView02.setImageDrawable(getResources().getDrawable( R.drawable.photo)); /* 用OnClickListener 事件来启动*/ mButton01.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { /* 当启动后, ImageView 立刻换背景图*/ mImageView01.setImageDrawable(getResources().getDrawable( R.drawable.right)); } }); mButton02.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { mImageView01.setImageDrawable(getResources().getDrawable( R.drawable.left)); } }); } }
ImageButton 的堆叠应用
① 新建项目
② 准备三张png 图片
left.png right.png photo.png
③ 修改main.xml 布局,添加UI 元素
<?xml version="1.0" encoding="utf-8"?> <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ImageButton android:id="@+id/myImageButton_Back" android:state_focused="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="36px" /> <ImageButton android:id="@+id/myImageButton_Photo" android:state_focused="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_x="0px" android:layout_y="36px" /> </AbsoluteLayout>
④ 修改mainActivity.java
设置成堆叠
package zyf.Ex_Ctrl_7_B; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ImageButton; public class Ex_Ctrl_7_B extends Activity { /** Called when the activity is first created. */ /*声明ImageButton*/ private ImageButton back_Imagebutton,photo_Imagebutton; private boolean Tag=true; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /*从XML中获取控件对象*/ back_Imagebutton=(ImageButton)findViewById(R.id.myImageButton_Back ); photo_Imagebutton=(ImageButton)findViewById(R.id.myImageButton_Photo ); //设置默认的背景图片 back_Imagebutton.setBackgroundResource(R.drawable.left); photo_Imagebutton.setBackgroundResource(R.drawable.photo); //给ImageButton设置事件监听器 photo_Imagebutton.setOnClickListener(new ImageButton.OnClickListener(){ @Override public void onClick(View v) { // TODO Auto-generated method stub Tag=!Tag;//更改背景图片 if(Tag){ back_Imagebutton.setBackgroundResource(R.drawable.right); }else{ back_Imagebutton.setBackgroundResource(R.drawable.left); } } }); } }
- Android_基础UI编程.zip (14.3 KB)
- 下载次数: 3
发表评论
-
Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
2015-12-18 22:23 479转载请注明出处:http:// ... -
android arcgis map应用
2013-10-14 20:11 13471 符号渲染 1.1 Symbol Symbol主要是对Gr ... -
lost android 开发教程二
2012-04-19 13:13 1827第二季课程介绍 1、控件使用方法介绍 Sprinner, ... -
android基础
2011-08-10 21:23 996lost in android Linux 环境 ... -
3G应用开发之Android
2011-04-10 21:12 1623什么是3G 3G,全称为3rd Generation,中文含义 ... -
扫雷游戏
2011-02-25 16:32 1213MineSweeper是一个不错的Android开源扫雷游戏, ... -
应用、permission、资源
2011-02-25 13:45 1441应用 为程序添加Menu菜单 //创建OptionsMenu ... -
文件存取、数据库编程
2011-02-25 13:41 692文件存取、数据库编程 -
新版Android开发可视化UI设计DroidDraw
2011-02-24 15:16 1215新版Android开发可视化UI设计DroidDraw -
Android UI编程基础3
2011-02-23 09:11 1058Android UI编程基础 EditText 与TextVi ... -
Android 基础UI编程2
2011-02-21 10:29 1041Android 基础UI编程 标题、状态栏的隐藏 标题栏隐藏 ... -
Android 基础UI编程1
2011-02-18 15:45 923Android 基础UI编程 更改与显示文字标签 TextVi ... -
android开发--布局
2011-02-17 16:25 1024Android应用开发3 使用Bundle在Activity间 ... -
Android 模拟器
2011-02-17 15:40 1431Android 模拟器 模拟器参数 参数格式 option 选 ... -
Android开发--Dalvik ADB
2011-02-17 10:41 1502Android虚拟机Dalvik Dalvik冲击 随着Goo ... -
Android开发环境搭建
2011-02-17 09:38 1311Android开发环境搭建 ADV的创建 ADT0.9.1 版 ... -
基础入门一
2011-02-17 09:12 1052开放手机联盟--Open HandsetAlliance 什么 ...
相关推荐
Android基础UI编程.pdf
新编Android基础UI编程[PDF].rar
新编Android开发教程之—— 基础UI编程,PDF清淅版,Google手机编程朋友的必看教程,基础UI编程面向初级用户介绍一些基础知识,并通过实战去加深对理论的理解。
Android_基础UI编程[1].pdf
教程名称: 老罗Android开发视频教程-Android常用UI控件编程【32集】【】Android常用UI控件编程第七集【】Android常用UI控件编程第二十三集【】Android常用UI控件编程第二十九集【】Android常用UI控件编程第二十二...
新版Android开发教程笔记基础UI编程4
新版Android开发教程 笔记10--基础UI编程4
新版Android开发教程-基础UI编程
Android文件存取和数据库编程UI编程,PDF文档。
Android开发教程-基础UI编程 android的各种控件
Android开发笔记,UI基础编程,PDF文档。
Android开发教程+笔记十-基础UI编程4.pdf
老罗Android开发视频教程 (android常用UI编程) 26-33集源码.zip
Android开发教程 笔记--基础UI编程
应用3、4 布局.Android开发教程+笔记7--基础UI编程1.Android开发教程+笔记8--基础UI编程2.Android开发教程+笔记9--基础UI编程3.Android开发教程+笔记10--基础UI编程4.Android开发教程+笔记11--可视化UI设计DroidDraw...