第九章 Android-UI组件(2)
一、图像视图(ImageView)
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:stretchColumns="*"
android:layout_gravity="center"
android:id="@+id/Tablelayout01">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bt1"
android:text="text1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bt2"
android:text="text1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/bt3"
android:text="text1"/></LinearLayout>
<ImageView
android:id="@+id/iv"
android:scaleType="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/plane"/>
</LinearLayout>
逻辑
package com.example.administrator.app1; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView; public class MainActivity extends AppCompatActivity {
private Button btn1,btn2,btn3;
private int alpha=255;
private int curr=0;
private int[] colors={R.drawable.bg_grey,R.drawable.bg_login,R.drawable.frame,R.drawable.logo};
private ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn1=(Button)findViewById(R.id.bt1);
btn2=(Button)findViewById(R.id.bt2);
btn3=(Button)findViewById(R.id.bt3);
btn1.setOnClickListener(new MyListener());
btn2.setOnClickListener(new MyListener());
iv=(ImageView)findViewById(R.id.iv);
btn3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
iv.setImageResource(colors[curr++%colors.length]);
}
}); }
class MyListener implements View.OnClickListener{
@Override
public void onClick(View v) {
if(v.equals(btn1)) {
Log.i("tag","11111");
alpha-=20;
if(alpha>=255){
alpha=255;
}
Log.i("tag","11111222222");
} else if(v==btn2) {
Log.i("tag","2222");
alpha-=20;
if(alpha<=0)
{
alpha=0;
}
Log.i("tag","22222333333");
}
Log.d("tag", alpha+"");
iv.setImageAlpha(alpha);
} }
}
二、逻辑
package com.example.administrator.app1; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.List; public class MainActivity extends AppCompatActivity {
private ListView lv;
private List<String> list;
private ArrayAdapter aa;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv=(ListView) findViewById(R.id.lv);
//新建数据源
list=new ArrayList<String>();
for(int i=0;i<=20;i++)
{
list.add("listview子项"+i);
}
//新建适配器,将数据绑定到适配器
aa=new ArrayAdapter(MainActivity.this, android.R.layout.simple_list_item_1,list);
//试图加载适配器
lv.setAdapter(aa); }
}
布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.administrator.app2.MainActivity">
<AutoCompleteTextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:dropDownHeight="100dp"
android:completionHint=""
android:background="@color/colorAccent"
android:dropDownWidth="match_parent"
android:id="@+id/actv"/>
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="btn"
android:id="@+id/btn"/>
</LinearLayout>
第九章 Android-UI组件(2)的更多相关文章
- 第九章:四大组件之Broadcast Receiver
第九章:四大组件之Broadcast Receiver 一.广播的功能和特征 广播的生命周期很短,经过调用对象-->实现onReceive-->结束,整个过程就结束了.从实现的复杂度和 ...
- Android UI组件----ListView列表控件详解
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
- Android 高级UI设计笔记08:Android开发者常用的7款Android UI组件(转载)
Android开发是目前最热门的移动开发技术之一,随着开发者的不断努力和Android社区的进步,Android开发技术已经日趋成熟,当然,在Android开源社区中也涌现了很多不错的开源UI项目,它 ...
- 这是一个比较全的Android UI 组件
Android组件及UI框架大全 原文地址:http://blog.csdn.net/smallnest/article/details/38658593 Android 是目前最流行的移动操作系统 ...
- Android UI组件学习
android.view.View类是全部UI组件的父类. 如果一些属性的内容本类找不到的时候一定要到父类之中进行查找. 所谓的学习组件的过程就是一个文档的查找过程. ※ Android之中所有的组件 ...
- 【ALearning】第四章 Android Layout组件布局(一)
在本章中,我们将Android学习组件布局.在前面的章节,我们也开始使用LinearLayout布局.然后我们在布局文件更加具体的学习和理解,会. Android的界面是有布局和组件协同完毕的,布局好 ...
- Android UI组件:布局管理器
为了更好的管理Android应用的用户界面中的组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常,推荐使用布局管理器来管理组件的分布. ...
- Android UI组件----AppWidget控件入门详解
Widget引入 我们可以把Widget理解成放置在桌面上的小组件(挂件),有了Widget,我们可以很方便地直接在桌面上进行各种操作,例如播放音乐. 当我们长按桌面时,可以看到Widget选项,如下 ...
- Android UI 组件 » GifView
GifView 是一个为了解决android中现在没有直接显示gif的view,只能通过mediaplay来显示这个问题的项目,其用法和 ImageView一样,支持gif图片 使用方法: 1-把Gi ...
- Android UI组件----自定义ListView实现动态刷新
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...
随机推荐
- ipa和ironic-conductor交互
IPA使用lookup和hearteat机制与Ironic Conductor进行交互,启动时agent给Conductor的vendor_passthru lookup endpoint(地址为/v ...
- 实时流处理Storm、Spark Streaming、Samza、Flink孰优孰劣
对于一个成熟的消息中间件而言,消息格式不仅关系到功能维度的扩展,还牵涉到性能维度的优化.随着Kafka的迅猛发展,其消息格式也在不断的升级改进,从0.8.x版本开始到现在的1.1.x版本,Kafka的 ...
- BZOJ 2223 [Coci 2009]PATULJCI | 主席树练习 (好像是个权限题啊)
题目: 给个序列,问[l,r]区间内是否存在x>(r-l+1)>>1 题解: 好像大家都觉得这个题比较简单,没人写题解啊 先说BZOJ样例的格式应该是,第二个数是序列中数的范围(就是 ...
- BZOJ4824 [Cqoi2017]老C的键盘 【树形dp】
题目链接 BZOJ4824 题解 观察出题目中的关系实际上是完全二叉树的父子关系 我们设\(f[i][j]\)为以\(i\)为根的节点在其子树中排名为\(j\)的方案数 转移时,枚举左右子树分别有几个 ...
- 牛客 2018NOIP 模你赛2 T2 分糖果 解题报告
分糖果 链接:https://www.nowcoder.com/acm/contest/173/B 来源:牛客网 题目描述 \(N\) 个小朋友围成一圈,你有无穷个糖果,想把其中一些分给他们. 从某个 ...
- AI人工客服开发 小程序智能客服 智能客服微信小程序 智能客服系统怎么做 如何设计智能客服系统
今天我们就来给大家分享下如何做 小程序的智能客服问答系统. 首先请确保你的小程序在线客服已经开通使用,并使用代码自己对接好了,将客户的提问自动做了拦截,拦截到了你自己开发的接口上. 做好了拦截以后,我 ...
- libaio.so.1: cannot open shared object file
<pre code_snippet_id="275763" snippet_file_name="blog_20140404_1_5530152" nam ...
- 杭电oj2072
因为一直不能ac先发这里,希望有看到的大佬能指点一二. 先讲一下我的基本思路,首先将一整行数据保存在数组中,接着遍历数组,根据空格将每个单词存入二维数组中,最后遍历二维数组,找出其中不同的单词并计数. ...
- AUTOIT3设置用户包含目录
- Linux的日志错误级别
讯息等级 系统将讯息分为七个主要的等级,依序是由不重要排列到重要讯息等级: info:仅是一些基本的讯息说明而已: notice:比 info 还需要被注意到的一些信息内容: warning 或 wa ...