android - Change corner radius of Imageview at runtime -


hello guys here xml file. want change corner radius of imageview @ run time in such way corner radius of bitmap in imageview should changed . have idea how can perform task.

<relativelayout  xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/maincontainer"    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:gravity="center"    >   <tablelayout       android:id="@+id/firstpictable"      android:layout_width="102.5dp"      android:layout_height="200dp"      android:background="@drawable/tableborder"      android:layout_margintop="5dp"      android:padding="0.5dp"      android:layout_marginbottom="5dp"              >               <imageview          android:id="@+id/image1"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          android:scaletype="fitxy"           android:background="@android:color/white"          android:contentdescription="@string/app_name"          />    </tablelayout>    <tablelayout       android:id="@+id/secondtpictable"      android:layout_width="102.5dp"      android:layout_height="200dp"      android:layout_margintop="5dp"       android:background="@drawable/tableborder"       android:padding="0.5dp"       android:layout_torightof="@+id/firstpictable"      >       <imageview           android:id="@+id/image223"          android:layout_width="match_parent"          android:layout_height="match_parent"           android:focusable="true"          android:background="@android:color/white"          android:contentdescription="@string/app_name"          android:scaletype="fitxy"           />  </tablelayout>     <tablelayout       android:id="@+id/thirddtpictable"      android:layout_width="102.5dp"      android:layout_height="200dp"      android:layout_margintop="5dp"       android:layout_torightof="@+id/secondtpictable"       android:padding="0.5dp"       android:background="@drawable/tableborder"       android:gravity="center">      <imageview           android:id="@+id/image3"          android:layout_width="match_parent"          android:layout_height="match_parent"          android:background="@android:color/black"          android:scaletype="fitxy"          android:focusable="true"          android:contentdescription="@string/app_name"           />  </tablelayout> 

like romain guy wrote in blog [1], can draw rounded image implementing drawable , use canvas.drawroundrect()

if want vary corner radius @ runtime, can update property in drawable (a integer mcornerradius instance), , invoke invalidateself() trigger redraw.

[1] http://www.curious-creature.org/2012/12/11/android-recipe-1-image-with-rounded-corners/


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -