布局:

<?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的更多相关文章

  1. Android View和ViewGroup

    View和ViewGroup Android的UI界面都是由View和ViewGroup及其派生类组合而成的. 其中,View是所有UI组件的基类,而 ViewGroup是容纳这些组件的容器,其本身也 ...

  2. View、ViewGroup (转)

    Android原理揭秘系列之View.ViewGroup (转) Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGrou ...

  3. Android2.2 API中文文档——View

    概述 java.lang.Object ↳        android.view.View 已知直接子类: AnalogClock, ImageView, KeyboardView, Progres ...

  4. view, surfaceView, invalidate, postInvalidate, 刷新屏幕

    http://blog.csdn.net/linghu_java/article/details/9985489 1.view view在api中的结构 Java.lang.Object Androi ...

  5. Android(java)学习笔记95:Android原理揭秘系列之View、ViewGroup

    作过Android 应用开发的朋友都知道,Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGroup是容纳这些组件的容器, ...

  6. Android界面的View以及ViewGroup的区别

    因为这个问题会经常成为面试的热点,所以我们来谈谈View以及ViewGroup的区别. 先看看View及ViewGroup类关系    Android View和ViewGroup从组成架构上看,似乎 ...

  7. android View各属性详解

    一.有8个直接子类:AnalogClock, ImageView, KeyboardView, ProgressBar, SurfaceView, TextView, ViewGroup, ViewS ...

  8. Android原理View、ViewGroup

    Android的UI界面都是由View和ViewGroup及其派生类组合而成的.其中,View是所有UI组件的基类,而ViewGroup是容纳这些组件的容器,其本身也是从View派生出来的.Andro ...

  9. View与ViewGroup有什么区别?

    百度知道:http://zhidao.baidu.com/link?url=B5MFOzDlww8soYqr5CL5FldH4sXD6eumS1XTRn8XEh8gu4mKjQdPkJSLIBt7u_ ...

随机推荐

  1. vim 折叠技巧

    转自:http://www.2cto.com/os/201203/122133.html 主要命令: zf-创建折叠 zf20G--创建折叠,从当前行折叠到第20行 zfgg--创建折叠,从当前位置折 ...

  2. (原)使用intel的ipp库计算卷积及相关

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5462631.html 参考网址: https://software.intel.com/zh-cn/n ...

  3. YUI的UA检测

    YUI.UA是针对javascript的宿主环境检测的一个检测对象,返回的是一系统关于当前宿主的信息 1.对象相关信息列表及userAgent 检测对象o = { ie: 0, //ie Mozill ...

  4. CSS的伪类和伪元素

    伪类 W3C:"W3C" 列指示出该属性在哪个 CSS 版本中定义(CSS1 还是 CSS2). 属性 描述 CSS :active 向被激活的元素添加样式. 1 :focus 向 ...

  5. django--的第一个项目hello world

    第一步: 用django-admin命令开始一个项目 cd /tmp/ django-admin startproject firstproject tree /tmp/firstproject 第二 ...

  6. 检测页面的localstorage剩余容量

    首先用了JSON.stringify(localStorage).length得出你当前页面的localstorage所使用的字符数量current_num. 然后你再去http://arty.nam ...

  7. COM组件开发实践(七)---多线程ActiveX控件和自动调整ActiveX控件大小(上)

    声明:本文代码基于CodeProject的文章<A Complete ActiveX Web Control Tutorial>修改而来,因此同样遵循Code Project Open L ...

  8. FZU1862(线段树 或者 DP)

    Problem 1862 QueryProblem Accept: 100    Submit: 249Time Limit: 2000 mSec    Memory Limit : 32768 KB ...

  9. 安全运维之:Linux系统账户和登录安全

    一.合理使用Shell历史命令记录功能 在Linux下可通过history命令查看用户所有的历史操作记录,同时shell命令操作记录默认保存在用户目录下 的.bash_history文件中,通过这个文 ...

  10. HTML5 canvas translate() 方法

    HTML5 canvas translate() 方法 translate() 方法重新映射画布上的 (0,0) 位置.