欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

旋轉(zhuǎn)ImageView和TextView的效果實(shí)現(xiàn)

系統(tǒng) 1661 0
旋轉(zhuǎn)ImageView和TextView的效果實(shí)現(xiàn)

如圖ImageView和TextView組成布局同時(shí)旋轉(zhuǎn)。,求實(shí)現(xiàn)效果。
經(jīng)過幾天研究終于實(shí)現(xiàn)如圖效果。代碼如下,給需要的人吧。還涉及到部分背景圖的效果。
    
public class IconViewGroup extends ViewGroup{
        TextView mTextView;
        ImageView mImageView;//顯示對應(yīng)的icon
        private Context mContext;
        /**
         * 命名區(qū)域
         */
        private final String namespace = "http://com.oppo.examples"; 
        /**
         * 保存創(chuàng)建旋轉(zhuǎn)角度
         */
        private float mRotateDegrees; 
        /**
         * 保存創(chuàng)建背景圖片的ID
         */
        private int mBackGroudDrawableId;
        /**
         * 利用圖片ID加載圖片
         */
        private Drawable mBackGroudDrawable;
        /**
         * 原始圖片所需寬、高
         */
        private int mBackGroundWidth;
        private int mBackGroundHeight;
        private View view;
        
        private static final int ICON_WIDTH=46;//顯示數(shù)字的TextView的長寬
        private static final int ICON_HEIGHT=46;
        
        private static final int TEXT_WIDTH=46;//顯示數(shù)字的TextView的長寬
        private static final int TEXT_HEIGHT=260;
        
        public IconViewGroup(Context context) {
                super(context);
                // TODO Auto-generated constructor stub
        }
        public IconViewGroup(Context context, AttributeSet attrs) {
                super(context, attrs);
                init(context);
                mContext = context;
                mBackGroudDrawableId=attrs.getAttributeResourceValue(namespace, "background", R.drawable.item_on);
                mBackGroudDrawable = context.getResources().getDrawable(
                                mBackGroudDrawableId);                
                mRotateDegrees=attrs.getAttributeFloatValue(namespace, "rotateDegrees",30.0f);                
        }

        private void init(Context context) {
                // TODO Auto-generated method stub
                mTextView=new MyTextView(context);
                mTextView.setTextSize(28);
                mTextView.setGravity(Gravity.CENTER_VERTICAL);
//                mTextView.setBackgroundColor(0xFFFFFF00);
                mTextView.setText(R.string.app_name);
                mTextView.setTextColor(0xF0FFFFFF);
                mImageView=new ImageView(context);
                mImageView.setBackgroundResource(R.drawable.icon);
                this.addView(mTextView);
                this.addView(mImageView);
        }

        @Override
        protected void onLayout(boolean changed, int l, int t, int r, int b) {
                // TODO Auto-generated method stub
                int ivWidth=mImageView.getMeasuredWidth();
                int ivHeight=mImageView.getMeasuredHeight();
                int tvWidth=mTextView.getMeasuredWidth();
                int tvHeight=mTextView.getMeasuredHeight();
                mTextView.measure(r - l, b - t);
                mTextView.layout(5+ivWidth+10, getHeight()-tvHeight-5,getWidth(),getHeight()-5);
                mImageView.measure(r - l, b - t);
                mImageView.layout(5, 5+getHeight()-ivHeight, ivWidth,getHeight());

        }
        
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                // TODO Auto-generated method stub
                super.onMeasure(widthMeasureSpec, heightMeasureSpec);
                /**
                 * 設(shè)定View顯示區(qū)域
                 */
                mBackGroundHeight=mBackGroudDrawable.getIntrinsicHeight();
                mBackGroundWidth=mBackGroudDrawable.getIntrinsicWidth();
                if (mRotateDegrees==90.0f) {
                        setMeasuredDimension(mBackGroundHeight, mBackGroundWidth);
                } else {
                        setMeasuredDimension(mBackGroundWidth, mBackGroundHeight);
                }                
        }
        
        @Override
        protected void dispatchDraw(Canvas canvas) {
                // TODO Auto-generated method stub
                canvas.rotate(mRotateDegrees);
                mBackGroudDrawable.setBounds(0, 0, mBackGroundWidth, mBackGroundHeight);
                mBackGroudDrawable.draw(canvas);
                super.dispatchDraw(canvas);
        }        
        
}

  


Android中ViewGroup等容器控件的使用
http://blog.csdn.net/arui319/archive/2010/09/07/5868466.aspx

旋轉(zhuǎn)ImageView和TextView的效果實(shí)現(xiàn)


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产精品视频免费一区二区三区 | 亚洲综合综合在线 | 亚洲第一色视频 | 国产 麻豆 | 久久中文字幕一区二区三区 | 亚洲1区 | 色福利网 | 国产精品一区二区免费 | 91中文字幕在线观看 | 色婷婷国产精品欧美毛片 | 奇米色777| 夜夜夜操操操 | 日本三级香港三级网站 | 久久精品伊人网 | 亚洲电影免费观看高清完整版在线观 | 色婷婷色综合缴情在线 | 97国产精品人妻无码久久久 | 天天插一插 | 国产精品观看在线亚洲人成网 | 久久久日韩精品一区二区 | 最新一区二区三区 | 免费黄色电影在线观看 | 日韩欧美在线观看 | 日韩黄色在线视频 | 亚洲一区二区久久 | 在线欧美日韩 | 天天操综合网 | 男女性刺激爽爽免费视频 | 日本人69视频jizz免费看 | 热久久免费 | 猫咪人成免费网站在线观看 | 免费观看一区二区三区毛片 | 亚洲综合激情另类小说区 | 欧美黑人伦理 | 草草影院地址 | 91探花 | 欧美色欧美亚洲高清在线视频 | 久草综合网 | 天天干干 | 国产网站大全 | 欧美一区二区三区中文字幕 |