图片走廊
16lz
2021-01-23
<ImageSwitcher android:id="@+id/switcher" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" /> //上面ImageSwitcher是用来显示图片那块区域的控件 <Gallery android:id="@+id/gallery" android:background="#55000000" android:layout_width="fill_parent" android:layout_height="60dp" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:gravity="center_vertical" android:spacing="16dp" />//Gallery 是来控制低下那个图标列表索引用的 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);//是使这个Activity没有titleBar,进而这个图片显示区域会增大//下面对BaseAdapter 进行了封装,这里是定义自己的适配器,其中getView()返回要显示的那个ImageView public class ImageAdapter extends BaseAdapter { public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView i = new ImageView(mContext); //动态生成一个ImageView i.setImageResource(mThumbIds[position]);//设置这张图片的源文件 i.setAdjustViewBounds(true); i.setLayoutParams(new Gallery.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));//设置图片框的大小 i.setBackgroundResource(R.drawable.picture_frame);//设置图片的背景 return i; } private Context mContext; }
更多相关文章
- 【Android】安卓中常用的图片加载方法
- Android 在程序界面上显示图片
- ImageVIew 设置图片大小
- Android: 背景图片平铺要这么干
- Android——Gallery 图片拖动效果
- Android ImageView图片自适应
- android异步图片加载三之handler+线程池+消息队列模式
- Android 图片侧滑展示RecyclerView简单实用
- Android 制作.9.png图片之利用Android 9-patch shadow generator