一、图像视图(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. wxPython 安装 及参考文档

    三种操作平台上的安装方法 1.windows 和 mac pip install -U wxPython 2.linux pip install -U -f https://extras.wxpyth ...

  2. 2013 ACM/ICPC Asia Regional Changsha Online – C题 Color Representation Conversion (坑爹模拟题)

    题意:给你三种颜色表示模式,RGB,HSV和HSL,实现任意模式之间两两转化. 1.最好别看题目中给的转化公式描述,我觉得叙述的一点也不清楚,看维基百科,把维基百科上的公式一句一句翻译过来就好 2.在 ...

  3. [常识]Windows系统里休眠和睡眠的区别?

    睡眠和休眠都是笔记本电脑的节能方式,但有细微的差别: 睡眠还保持着开机状态的,休眠是关机了,但是再次开机之后和关闭时的系统状态是一样的. 睡眠还是保持着系统运行数据在内存中,而休眠则将内存中的数据保存 ...

  4. maven学习(十七)——在eclipse中导入外部maven项目

    外部maven项目,导入Eclipse中进行开发 操作步骤如下所示:

  5. 一步步制作RPM包

    一步步制作RPM包 来源 http://blog.51cto.com/laoguang/1103628 一.RPM制作步骤 我们在企业中有的软件基本都是编译的,我们每次安装都得编译,那怎么办呢?那就根 ...

  6. Sublime Text 2注册码

    出处不详. ----- BEGIN LICENSE ----- Andrew Weber Single User License EA7E-855605 813A03DD 5E4AD9E6 6C0EE ...

  7. transform perspective的层级问题

    如上图,在积分的数字元素上,使用了transform perspective,其层级就穿透了上面的遮罩层,关键代码如下: .mask { position: fixed; z-index:; } .f ...

  8. AE中实现Control中的各种图形工具的方法

    添加命名空间 using ESRI.ArcGIS.SystemUI;using ESRI.ArcGIS.Controls; A类:前面有Controls 后面有tool的工具都可以用同一类的代码实现( ...

  9. HDU3605:Marriage Match IV

    Marriage Match IV Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  10. bzoj 4443 [Scoi2015]小凸玩矩阵 网络流,二分

    [Scoi2015]小凸玩矩阵 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1564  Solved: 734[Submit][Status][Di ...