本文介绍了如何在Android Studio上制作圆形的(带圆圈的)ImageView框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Android Studio中创建圆角的图像视图而不是正方形(类似于Whats-app中的正方形).
I am trying to create rounded shape Image-view not the square shape in Android Studio (like the one from Whats-app).
这是我的xml文件
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="schemas.android/apk/res/android" xmlns:tools="schemas.android/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:background="@drawable/background" tools:context="com.example.ska89.xxxxxx.MainActivity"> <ImageView android:layout_width="150dp" android:layout_height="150dp" android:id="@+id/imageView2" android:src="@drawable/logo" android:layout_marginTop="64dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:adjustViewBounds="false" android:clickable="false" /> </RelativeLayout>谢谢.
推荐答案在您的drawable文件夹中创建一个xml文件(例如circle_shape.xml),然后编写类似以下的代码
Create a xml file e.g circle_shape.xml in your drawable folder and write the following code something like this
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="schemas.android/apk/res/android" android:shape="oval"> <solid android:color="@color/colorRound"/> <size android:width="50dp" android:height="50dp"/> </shape>然后在您的imageView中使用circle_shape.xml作为背景
then use this circle_shape.xml in your imageView as background something like this
<ImageView android:layout_width="150dp" android:layout_height="150dp" android:id="@+id/imageView2" android:src="@drawable/logo" android:layout_marginTop="64dp" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:adjustViewBounds="false" android:background="@drawable/circle_shape" android:clickable="false" />更多推荐
如何在Android Studio上制作圆形的(带圆圈的)ImageView框?
发布评论