一、图像视图(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)的更多相关文章

  1. 第九章:四大组件之Broadcast Receiver

    第九章:四大组件之Broadcast Receiver   一.广播的功能和特征 广播的生命周期很短,经过调用对象-->实现onReceive-->结束,整个过程就结束了.从实现的复杂度和 ...

  2. Android UI组件----ListView列表控件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  3. Android 高级UI设计笔记08:Android开发者常用的7款Android UI组件(转载)

    Android开发是目前最热门的移动开发技术之一,随着开发者的不断努力和Android社区的进步,Android开发技术已经日趋成熟,当然,在Android开源社区中也涌现了很多不错的开源UI项目,它 ...

  4. 这是一个比较全的Android UI 组件

     Android组件及UI框架大全 原文地址:http://blog.csdn.net/smallnest/article/details/38658593 Android 是目前最流行的移动操作系统 ...

  5. Android UI组件学习

    android.view.View类是全部UI组件的父类. 如果一些属性的内容本类找不到的时候一定要到父类之中进行查找. 所谓的学习组件的过程就是一个文档的查找过程. ※ Android之中所有的组件 ...

  6. 【ALearning】第四章 Android Layout组件布局(一)

    在本章中,我们将Android学习组件布局.在前面的章节,我们也开始使用LinearLayout布局.然后我们在布局文件更加具体的学习和理解,会. Android的界面是有布局和组件协同完毕的,布局好 ...

  7. Android UI组件:布局管理器

    为了更好的管理Android应用的用户界面中的组件,Android提供了布局管理器.通过使用布局管理器,Android应用的图形用户界面具有良好的平台无关性.通常,推荐使用布局管理器来管理组件的分布. ...

  8. Android UI组件----AppWidget控件入门详解

    Widget引入 我们可以把Widget理解成放置在桌面上的小组件(挂件),有了Widget,我们可以很方便地直接在桌面上进行各种操作,例如播放音乐. 当我们长按桌面时,可以看到Widget选项,如下 ...

  9. Android UI 组件 » GifView

    GifView 是一个为了解决android中现在没有直接显示gif的view,只能通过mediaplay来显示这个问题的项目,其用法和 ImageView一样,支持gif图片 使用方法: 1-把Gi ...

  10. Android UI组件----自定义ListView实现动态刷新

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

随机推荐

  1. JavaWeb笔记(八)JQuery

    三个版本 1.x:兼容 ie678,使用最为广泛的,官方只做BUG维护, 功能不再新增.因此一般项目来说,使用1.x版本就可以了 最终版本:1.12.4 2.x:不兼容ie678,很少有人使用,官方只 ...

  2. 那些牛掰的 HTML5的API(二)

    1:视频播放器 2:地理定位 我们的支持html5 的浏览器给我们提供一个接口(api),可以用来获取你当前的位置. 主要是通过geolocation(地理位置),对象 ,去访问硬件,来获取到经纬度. ...

  3. 【bzoj2793】[Poi2012]Vouchers 暴力

    题目描述 考虑正整数集合,现在有n组人依次来取数,假设第i组来了x人,他们每个取的数一定是x的倍数,并且是还剩下的最小的x个.正整数中有m个数被标成了幸运数,问有哪些人取到了幸运数. 输入 第一行一个 ...

  4. Dom的深度优先遍历和广度优先遍历

    //深度优先遍历的递归写法 function DFTraversal(node) { var nodes = []; if (node != null) { nodes.push(node); var ...

  5. 原生方法scrollTo支持滚动特效

    scrollTo默认的是瞬间滚动到坐标位置, 使用配置方法, behavior属性设置为smooth就可以支持平滑滚动了,不过这种方法兼容性不行,并且无法支持配置滚动速率 // 默认滚动效果,瞬时滚动 ...

  6. quartz 调度

    1.POI文件中导入包      <dependency> <groupId>org.quartz-scheduler</groupId> <artifact ...

  7. DotNETCore 学习笔记 路由

    Route ------------------------------------------constraint------------------------------------------ ...

  8. gdb 查看变量~p长串末尾省略号, 一个页面显示不完

    # MQClientAPIImpl::getTopicRouteInfoFromNameServer () at MQClientAPIImpl.cpp: # # # # # # # # # , ar ...

  9. Linux SPI总线和设备驱动架构之一:系统概述【转】

    转自:http://blog.csdn.net/droidphone/article/details/23367051/ 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[-] 硬 ...

  10. 华为上机测试题(水仙花数升级版-java)

    PS:这题满分100,没有做对,大家帮忙看看问题在哪 /* * 题目:水仙花数升级版  * 描述: 水仙花数是指一个 n 位数 ( n≥3 ),它的每个位上的数字的 n 次幂之和等于它本身.(例如:1 ...