Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My best suggestion is to wrap your <a href="http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html" rel="noreferrer">BitmapDrawable</a> with a <a href="http://developer.android.com/reference/android/graphics/drawable/ClipDrawable.html" rel="noreferrer">ClipDrawable</a>.</p> <p>ClipDrawable lets you define clipping for any other drawable, so instead of drawing the entire drawable, only a part of it will be drawn.</p> <p>How would that work? Your ImageView can display a drawable - assignable through <code>setImageDrawable()</code>. Naturally, you would place a BitmapDrawable of your image bitmap there. If you wrap your BitmapDrawable first with ClipDrawable, and only then assign to the ImageView, you should be fine. </p> <pre><code>&lt;ImageView android:id="@+id/imageView1" android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/clip_source" /&gt; </code></pre> <p>and this is <code>clip_source</code> drawable:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;clip xmlns:android="http://schemas.android.com/apk/res/android" android:clipOrientation="vertical" android:drawable="@drawable/your_own_drawable" android:gravity="top" /&gt; </code></pre> <p>You can define the amount of clipping by calling the function <code>setLevel()</code> on your ClipDrawable (<code>clip_source</code>). A level of 0 means the image is completely hidden and a level of 10000 means the image is completely revealed. You can use any int value in the middle.</p> <p>You'll have to set the level in code, so your code should first get a reference to the ClipDrawable. You can do this by running <code>getDrawable()</code> on your ImageView instance. When you have a reference to your ClipDrawable, simply run <code>setLevel(5000)</code> on it (or any other number 0-10000).</p> <pre><code>ImageView img = (ImageView) findViewById(R.id.imageView1); mImageDrawable = (ClipDrawable) img.getDrawable(); mImageDrawable.setLevel(5000); </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