zoukankan      html  css  js  c++  java
  • new LayoutParams 使用


              ImageView imageView = new ImageView(mcontext); LayoutParams layoutParams = new LayoutParams(150,130); layoutParams.leftMargin=20; // layoutParams.leftMargin imageView.setLayoutParams(layoutParams); //添加view 到layout imageView.setScaleType(ScaleType.FIT_XY); imageView.setBackgroundResource(R.drawable.shape_border_img); ImageLoader.getInstance().displayImage(productslist.get(i).getPimg(), imageView); viewHolder.product_img_lin.addView(imageView); // layout加上imageview
    
    

    第二种 : 

    // 创建LinearLayout
        LinearLayout linearLayout = new LinearLayout(this);
        linearLayout.setOrientation(LinearLayout.VERTICAL);
        linearLayout.setLayoutParams(new LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        // Creates a new ImageView
        ImageView imageView = new ImageView(this);
        // Sets the bitmap for the ImageView from an icon bit map (defined
        // elsewhere)
        imageView.setImageResource(R.drawable.play);
        // 或者通过名字来获取,int id = getResources().getIdentifier("gameover",
        // "drawable", getPackageName());
        int id = getResources().getIdentifier("play", "drawable",
            getPackageName());
        imageView.setImageResource(id);
        // setting image position
        imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT));
        // Sets the tag
        imageView.setTag(IMAGEVIEW_TAG);
        // adding view to layout
        linearLayout.addView(imageView);
        // make visible to program
        setContentView(linearLayout);
  • 相关阅读:
    GDB 运行PYTHON 脚本+python 转换GDB调用栈到流程图
    GDB-Dashboard-GDB可视化界面
    使用gdb调试Python进程
    从底层理解Python的执行
    python 用pdb调试
    GDB反向调试 + 指令记录+函数历史记录
    linux 0.11 源码学习+ IO模型
    LINUX系统全部参数 sysctl -a + 网络参数设置
    Linux Kernel 排程機制介紹
    linux 系统调优2
  • 原文地址:https://www.cnblogs.com/java-g/p/4235518.html
Copyright © 2011-2022 走看看