Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is one of solution in which you have to <code>make round to your main layout background</code> and inside keep your <code>imageview with your desire image:</code></p> <p>something like below:</p> <p><em>back.xml</em></p> <p><em>This will make your image to round corner</em></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"&gt; &lt;stroke android:width="1dp" android:color="#dd7b7a"/&gt; &lt;corners android:bottomRightRadius="10dp" android:bottomLeftRadius="10dp" android:topLeftRadius="10dp" android:topRightRadius="10dp"/&gt; &lt;solid android:color="#dd7b7a"/&gt; &lt;/shape&gt; </code></pre> <p><em>tile_mode.xml</em></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/background" android:tileMode="repeat" /&gt; </code></pre> <p><em>layout.xml</em></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" &gt; &lt;LinearLayout android:padding="4dip" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/back" android:gravity="center_horizontal" &gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/tile_mode" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p><strong>Updated</strong></p> <p>After digging lots, I came across on of solution which already posted on <code>stackoverflow</code> </p> <p><a href="https://stackoverflow.com/questions/9517434/changing-image-as-rounded-corner">Changing Image as Rounded Corner</a></p> <p><a href="https://stackoverflow.com/questions/2459916/how-to-make-an-imageview-to-have-rounded-corners">How to make an ImageView to have rounded corners</a></p> <p>step1@</p> <p><em>main.xml</em></p> <pre><code> &lt;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:gravity="center" tools:context=".MainActivity" &gt; &lt;ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Step2@</p> <p>Make one function which make rounded to your bitmap using canvas.</p> <pre><code>public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap .getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(output); final int color = 0xff424242; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); final float roundPx = pixels; paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); return output; } </code></pre> <p>step3@</p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageView image=(ImageView)findViewById(R.id.image); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.testing); image.setImageBitmap(getRoundedCornerBitmap(bitmap, 20)); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload