android:paddingLeft=“8dp”
android:paddingRight=“8dp”
android:textAppearance="?android:attr/textAppearanceMediumInverse" />
<TextView
android:id="@+id/textView1"
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_above="@+id/textView2"
android:layout_alignLeft="@+id/textView2"
android:layout_marginBottom=“4dp”
android:background="#7f000000"
android:paddingLeft=“8dp”
android:paddingRight=“8dp”
android:textAppearance="?android:attr/textAppearanceLargeInverse" />
如下图:
用代码创建 :
RoundedImageView iv = new RoundedImageView(context);
iv.setScaleType(ScaleType.CENTER_CROP);
iv.setCornerRadius(10);
iv.setBorderWidth(2);
iv.setBorderColor(Color.DKGRAY);
iv.setRoundedBackground(true);
iv.setImageDrawable(drawable);
iv.setBackground(backgroundDrawable);
iv.setOval(true);
贴上部分源码:
package com.makeramen;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
@SuppressWarnings(“UnusedDeclaration”)
public class RoundedImageView extends ImageView {
public static final String TAG = “RoundedImageView”;
public static final float DEFAULT_RADIUS = 0f;
public static fi