相关疑难解决方法(0)

如何使按钮的角落圆?

我想做一个button圆角.有没有一种简单的方法可以在Android中实现这一目标?

android rounded-corners android-button

429
推荐指数
13
解决办法
52万
查看次数

如何用Glide库舍入图像?

所以,有人知道如何使用Glide显示带圆角的图像吗?我正在使用Glide加载图像,但我不知道如何将舍入的参数传递给此库.

我需要显示图像如下例子:

在此输入图像描述

android android-glide

174
推荐指数
11
解决办法
13万
查看次数

如何在Android UI中绘制圆角矩形?

我需要在Android UI中绘制一个圆角矩形.具有相同的圆角矩形TextView,并EditText也将是有益的.

android textview android-edittext

127
推荐指数
3
解决办法
14万
查看次数

Android查看剪辑

有没有办法在android(Honeycomb)中定义ViewGroup的剪辑区域?例如,我有一个带有圆角的图像背景的ListView.当我滚动列表时,孩子们伸出背景的角落 - 我宁愿他们在圆角内剪辑. 左:未剪辑,右:剪裁

左图是它目前正在做的,右边是我想要的.

我在看ClipDrawable,但似乎这只能用于进度条?

此外,我正在尝试在小部件中执行此操作.所以我不能使用自定义视图并覆盖onDraw进行屏蔽.

谢谢!

java xml android clip android-layout

55
推荐指数
4
解决办法
3万
查看次数

裁剪方形图像到圆圈 - 以编程方式

我正在寻找过去的一天,但我没有成功.

我从API获取图像,然后使用以下代码将其下载到位图文件.

private Bitmap DownloadImage(String URL) 
    {
        Bitmap bitmap = null;
        InputStream in = null;
        try 
        {
            in = OpenHttpConnection(URL);
            bitmap = BitmapFactory.decodeStream(in);
            in.close();
        }
        catch (IOException e1) 
        {
            e1.printStackTrace();
        }
        return bitmap;
    }

    private InputStream OpenHttpConnection(String urlString) throws IOException 
    {
        InputStream in = null;
        int response = -1;

        URL url = new URL(urlString);
        URLConnection conn = url.openConnection();

        if (!(conn instanceof HttpURLConnection))
            throw new IOException("Not an HTTP connection");

        try 
        {
            HttpURLConnection httpConn = (HttpURLConnection) conn;
            httpConn.setAllowUserInteraction(false);
            httpConn.setInstanceFollowRedirects(true);
            httpConn.setRequestMethod("GET");
            httpConn.connect();

            response …
Run Code Online (Sandbox Code Playgroud)

android image crop android-canvas

21
推荐指数
3
解决办法
5万
查看次数

添加图像圆形图像android的边框

我有什么 ::我有一个Imageview,我使用picassso将图像作为一个圆圈 在此输入图像描述

我该怎么做 ::我想使用我当前的实现为圆形图像添加黑色边框,如何在不使用第三方库的情况下实现此目的

Picasso.with(this)
.load("http://i.imgur.com/DvpvklR.png")
.transform(new RoundedTransformation(50, 4))
.resize(100, 100)
.centerCrop().into(imageView1);
Run Code Online (Sandbox Code Playgroud)

RoundedTransformation.java

// enables hardware accelerated rounded corners
// original idea here : http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/
public class RoundedTransformation implements com.squareup.picasso.Transformation {
    private final int radius;
    private final int margin;  // dp

    // radius is corner radii in dp
    // margin is the board in dp
    public RoundedTransformation(final int radius, final int margin) {
        this.radius = radius;
        this.margin = margin;
    }

    @Override
    public Bitmap transform(final Bitmap source) {
        final Paint paint …
Run Code Online (Sandbox Code Playgroud)

android picasso

18
推荐指数
2
解决办法
2万
查看次数

Android - 在一个圆圈中显示ExoPlayer

我试图在一个圆圈内显示一个ExoPlayerView,覆盖另一个ExoPlayer(画中画): 在此输入图像描述

我已经尝试将第二个玩家放在一个带圆角的框架内(这个答案这一个)但是玩家将总是逃离父框架并绘制视频的完整矩形.

我发现这个解决方案使用了GLSurfaceView,但是这个解决方案使用的是经典的MediaPlayer而不是ExoPlayer.

android exoplayer

7
推荐指数
1
解决办法
761
查看次数

我可以使用setClipBounds剪辑带圆圈的视图吗?

我有以下代码来分隔要绘制的视图的区域:

Rect rect = new Rect();
rect.set(0, 0, 100, 100);
View.setClipBounds(rect);
Run Code Online (Sandbox Code Playgroud)

这将仅在指定的矩形(或在本例中为正方形)上绘制我的视图.但是,我希望将视图剪切为圆形.有没有办法以某种方式绕过Rect对象的角落?

android

3
推荐指数
1
解决办法
2975
查看次数

如何制作圆形表面视图

我正在尝试制作圆形的表面视图.我搜索了很多,但我找不到一个好的解决方案.我现在正在做的是,我将SurfaceView放入FrameLayout,然后将另一个View放在它上面,或者使用PNG蒙版,或者使用形状xml drawable.这里是

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_width="140dp"
        android:layout_height="140dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="#000"
        android:orientation="vertical"
        android:visibility="visible" >

        <FrameLayout
            android:id="@+id/videorecordview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_weight=".2" >

            <SurfaceView
            android:id="@+id/surfaceView1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
        </FrameLayout>
    </LinearLayout>

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/rounded"
        android:orientation="vertical" >
    </LinearLayout>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

但这不是一个好的解决方案,也不是完美的.我想将surfaceview自定义为圆形.任何帮助将非常感激.谢谢 :)

android surfaceview

1
推荐指数
2
解决办法
3814
查看次数