如何在Android Studio中使用JAVA创建一个圆形图像视图?

huangapple go评论55阅读模式
英文:

How should i create an circle image view in Android studio using JAVA

问题

I am making an app like Instagram in Android Studio using JAVA framework and Firebase for the backend.
我正在使用Android Studio和JAVA框架以及Firebase后端制作类似Instagram的应用。

I want to know how I can make a circle image view in it that can be used for a profile picture.
我想知道如何在其中创建一个可用于个人资料图片的圆形图像视图。

英文:

I am making an app like Instagram in Android Studio using JAVA framework and Firebase for the backend.
I want to know how i can make circle image view in it that can be used for profile picture.

答案1

得分: -1

我相信你正在寻找以下结果 -

如何在Android Studio中使用JAVA创建一个圆形图像视图?

你应该使用一个非常流行的库CircularImageView

将库添加到你的build.gradle(Module App)

implementation 'com.mikhaellopez:circularimageview:4.2.0'

你可以像在xml中创建ImageView一样创建ImageView。

<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="250dp"
android:layout_height="250dp"
android:src="@drawable/image"
app:civ_border_color="#3f51b5"
app:civ_border_width="4dp"
app:civ_shadow="true"
app:civ_shadow_radius="10"
app:civ_shadow_color="#3f51b5"/>

在你的代码中,你可以引用相同的视图 -

CircularImageView circularImageView = findViewById(R.id.circularImageView);

请查看文档以获取更多自定义信息。

愉快编码!

英文:

I do believe you are looking for following result -

如何在Android Studio中使用JAVA创建一个圆形图像视图?

You should use a very popular library CircularImageView

Add library to your build.gradle(Module App)

implementation &#39;com.mikhaellopez:circularimageview:4.2.0&#39;

You can create image view just like you create ImageView in your xml.

&lt;com.mikhaellopez.circularimageview.CircularImageView
    android:layout_width=&quot;250dp&quot;
    android:layout_height=&quot;250dp&quot;
    android:src=&quot;@drawable/image&quot;
    app:civ_border_color=&quot;#3f51b5&quot;
    app:civ_border_width=&quot;4dp&quot;
    app:civ_shadow=&quot;true&quot;
    app:civ_shadow_radius=&quot;10&quot;
    app:civ_shadow_color=&quot;#3f51b5&quot;/&gt;

In you code you can referance same view as -

CircularImageView circularImageView = findViewById(R.id.circularImageView);

Please check the documentation for more customization.

Happy Coding !

huangapple
  • 本文由 发表于 2020年8月10日 22:20:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/63342057.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定