zoukankan      html  css  js  c++  java
  • 圆形图片

    //自定义控件

    package com.zcp.map;

    import android.content.Context;
    import android.graphics.Canvas;
    import android.graphics.Path;
    import android.graphics.RectF;
    import android.util.AttributeSet;
    import android.widget.ImageView;

    public class ImgView extends ImageView {

    public ImgView(Context context, AttributeSet attrs) {
    super(context, attrs);

    }
    @Override
    protected void onDraw(Canvas canvas) {
    Path clipPath = new Path();
    int w = this.getWidth();
    int h = this.getHeight();
    clipPath.addRoundRect(new RectF(0, 0, w, h), 200.0f, 200.0f,
    Path.Direction.CW);
    canvas.clipPath(clipPath);
    super.onDraw(canvas);
    }


    }

    //布局文件

    <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"
    tools:context=".MainActivity" >

    <com.zcp.map.ImgView
    android:id="@+id/img"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY" />

    </RelativeLayout>

    //Activity

    img=(ImgView)findViewById(R.id.img);
    img.setImageResource(R.drawable.x);

  • 相关阅读:
    HDU 1501 Zipper(DFS)
    HDU 2181 哈密顿绕行世界问题(DFS)
    HDU 1254 推箱子(BFS)
    HDU 1045 Fire Net (DFS)
    HDU 2212 DFS
    HDU 1241Oil Deposits (DFS)
    HDU 1312 Red and Black (DFS)
    HDU 1010 Tempter of the Bone(DFS+奇偶剪枝)
    HDU 1022 Train Problem I(栈)
    HDU 1008 u Calculate e
  • 原文地址:https://www.cnblogs.com/hnpy/p/5457234.html
Copyright © 2011-2022 走看看