Java 如何在android中选择的菜单项上将imageview形状更改为圆形?
我是新来的Java 如何在android中选择的菜单项上将imageview形状更改为圆形?,java,android,eclipse,Java,Android,Eclipse,我是新来的android,现在我被困在一个点上。 当用户在菜单项圆形上单击时,我想更改图像视图的形状 drawable文件夹中的mycircle\u shape.xml文件 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <corners
android
,现在我被困在一个点上。
当用户在菜单项圆形上单击时,我想更改图像视图的形状
drawable
文件夹中的mycircle\u shape.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:bottomLeftRadius="10dp"
android:topLeftRadius="10dp"
android:topRightRadius="10dp"
android:bottomRightRadius="10dp"/>
<solid android:color="#FF44FF"/>
</shape>
以及布局文件夹中的我的Shape.xml文件
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mixapp.Shape_with_Spinner" >
<Spinner
android:id="@+id/shapeSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:entries="@array/Spinner_value"/>
<ImageView
android:id="@+id/imgToShape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
任何帮助都是值得的。:) 我建议您使用或。这个libs不仅允许您异步加载图像,还可以为任何应该加载的图像设置转换(这里准备使用循环转换)。也许您只需要imgMaster.setImageDrawable(drawable)
?@Blackbelt现在让我试试。(y) @Blackbelt不工作:(我已经浏览了你提供的链接,但是明天我要考试,这样的libs就不存在了,那么有没有办法通过一些传统的方式让它变得简单,是Android studio的呢?我现在正在使用eclipse。@devin_child你可以试着使用这个源代码,我是通过为shape创建另一个XML文件来实现的,在java中,设置为t他可以画;
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.mixapp.Shape_with_Spinner" >
<Spinner
android:id="@+id/shapeSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:entries="@array/Spinner_value"/>
<ImageView
android:id="@+id/imgToShape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>