Gallery过时替代方案HorizontalScrollView
布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:background="#ff0000"
tools:context="me.chunsheng.hongbao.activities.GallaryActivity"> <ImageView
android:id="@+id/displayImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" /> <HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"> <LinearLayout
android:id="@+id/mygallery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView> </RelativeLayout>
代码:
package me.chunsheng.hongbao.activities; import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout; import java.io.IOException;
import java.io.InputStream; import me.chunsheng.hongbao.R; public class GallaryActivity extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gallary); final ImageView diplayImage = (ImageView) findViewById(R.id.displayImage);
final LinearLayout myGallery = (LinearLayout) findViewById(R.id.mygallery); try {
String galleryDirectoryName = "gallery";
String[] listImages = new String[3];
for (int i = 0; i < 4; i++) {
//InputStream is = getAssets().open(galleryDirectoryName + "/" + imageName);
//final Bitmap bitmap = BitmapFactory.decodeStream(is); ImageView imageView = new ImageView(getApplicationContext());
imageView.setLayoutParams(new ViewGroup.LayoutParams(700, 700));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.mayun);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
diplayImage.setImageResource(R.mipmap.bg_action_bar);
}
}); myGallery.addView(imageView);
}
} catch (Exception e) {
}
}
}
Gallery过时替代方案HorizontalScrollView的更多相关文章
- Android View和ViewGroup
View和ViewGroup Android的UI界面都是由View和ViewGroup及其派生类组合而成的. 其中,View是所有UI组件的基类,而 ViewGroup是容纳这些组件的容器,其本身也 ...
- View、ViewGroup (转)
Android原理揭秘系列之View.ViewGroup (转) Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGrou ...
- Android2.2 API中文文档——View
概述 java.lang.Object ↳ android.view.View 已知直接子类: AnalogClock, ImageView, KeyboardView, Progres ...
- view, surfaceView, invalidate, postInvalidate, 刷新屏幕
http://blog.csdn.net/linghu_java/article/details/9985489 1.view view在api中的结构 Java.lang.Object Androi ...
- Android(java)学习笔记95:Android原理揭秘系列之View、ViewGroup
作过Android 应用开发的朋友都知道,Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGroup是容纳这些组件的容器, ...
- Android界面的View以及ViewGroup的区别
因为这个问题会经常成为面试的热点,所以我们来谈谈View以及ViewGroup的区别. 先看看View及ViewGroup类关系 Android View和ViewGroup从组成架构上看,似乎 ...
- android View各属性详解
一.有8个直接子类:AnalogClock, ImageView, KeyboardView, ProgressBar, SurfaceView, TextView, ViewGroup, ViewS ...
- Android原理View、ViewGroup
Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGroup是容纳这些组件的容器,其本身也是从View派生出来的.Andro ...
- View与ViewGroup有什么区别?
百度知道:http://zhidao.baidu.com/link?url=B5MFOzDlww8soYqr5CL5FldH4sXD6eumS1XTRn8XEh8gu4mKjQdPkJSLIBt7u_ ...
随机推荐
- 显示查询记录的前n条 mysql limit用法
按时间倒序出所有的数据 mysql order by createtime desc ; +----+------------------+ | id | id_no | +----+-------- ...
- ie textarea不支持maxlength textarea限制长度
//ie textarea不支持maxlength $('#verify_note').bind('input propertychange', function() { if (this.value ...
- SSH 5W学习
what SSH的英文全称为Secure Shell,是IETF(Internet Engineering Task Force)的Network Working Group所制定的一族协议,其目的是 ...
- web_profile(网站分析)配置
web_profiler: # DEPRECATED, it is not useful anymore and can be removed # safely from your configura ...
- 利用radio实现纯css选项卡切换
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtIAAABCCAIAAAD18aaXAAAG70lEQVR4nO3dO5KrPBCGYRY0VV4OEX
- 1004 Anagrams by Stack
考察DFS的应用,用栈描述字符串的变化过程. #include <stdio.h> #include <string.h> int len1,len2; ],str2[],st ...
- C语言经典程序190例
[程序1] 题目:809*??=800*??+9*??+1 其中??代表的两位数,8*??的结果为两位数,9*??的结果为3位数.求??代表的两位数,及809*??后的结果. 1.程序分析: 2.程序 ...
- 【MVC4 之 ViewData ViewBag TempData】
ViewData (一个字典集合类型):传入的key必须是string类型,可以保存任意对象信息,特点:它只会存在这次的HTTP的要求中而已,并不像session可以将数据带到下一个Http要求. V ...
- 数据类型MSVC和gcc/g++的不同
前言: 在16位环境下,int/unsigned int 占16位,long/unsigned long占32位 在32位环境下,int占32位,unsigned int占16位,long/unsig ...
- RabbitMQ中文入门教程
原文地址:http://adamlu.net/dev/2011/09/rabbitmq-get-started/ 这系列教程是翻译官方入门教程. 第一部分:Hello World第二部分:工作队列(W ...