Help with cropping the top of an ImageView

by knavewave » Fri, 20 Nov 2009 15:33:41 GMT


Sponsored Links
 I am trying to place a background image within a HorizontalScrollView
such that the entire width of my image is scrollable and such that the
excess height will be cropped. This seems like it should be
straightforward: no scaling, no centering... just peg it to the bottom
left corner and lop off the top. After going through various
permutations of 'scaleType' and juggling things around the layout, I
am beginning to think I can do almost everything except for what I
described above :)

Here is a basic dump of my layout

<RelativeLayout
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  <HorizontalScrollView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true">
    <RelativeLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
      <ImageView
        android:id="@+id/BackgroundImage"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_width="XXX"
        android:layout_height="XXX"
        android:scaleType="XXX"

      ... Other UI elements

The closest I have got so far, is by using the 'scaleType=centerCrop".
This will give me the correct horizontal scrolling and vertical image
cropping (no scaling just clips the excess). The only problem, is that
the vertical clipping is such that an equal amount is clipped from
both the top and bottom, when what I am shooting for is to only have
the top clipped.

Please help! The amount of time I have sunk into this one problem is
beginning to be a bit embarrassing :)

--



Other Threads

1. OOT: bikinin stiker gini donk

Ada yg bisa buatin sticker gini gak?

Siapa tau aja..lutju sih

-- 
"Indonesian Android Community [id-android]" 

2. Adding menu items in a WebView context menu

Hi all,

I'm trying to add custom menu items in a WebView Context Menu.
Unfortunately, my items are shown in the menu of the first web page I
load , but then if I load a second page, a long press only shows the
standard context menu items. Mine are gone.

I've put a Toast inside the code and it is displayed as well on the
first loaded page, but not on the second.

I'm using the code below :

        @Override
        public void onCreateContextMenu(ContextMenu menu, View v,
                        ContextMenuInfo menuInfo) {
                contextMenu=menu;

                Toast.makeText(this, "getpicturefromweb", 
Toast.LENGTH_LONG).show();

                MenuItem menuItem=contextMenu.add("getpicturefromweb");
                menuItem.setEnabled(true);
                menuItem.setIcon(R.drawable.icon);

                super.onCreateContextMenu(menu, v, menuInfo);
        }

I think the context menu is repopulated depending on what you
longpress(link, image, ...) and I didn't find the correct hook.

I've read about a OnPopulateContextMenuListener hook, but I get a
unresolved import when I try to add it. Maybe it's deprecated but I
don't know I could not find it in the Api docs.

Last and not least, if someone knows how to solve the avobe, I'd like
to know if it's possible in some way to add my item only on specific
objects ?
Like a "Use this picture" on a picture.

Thanks in advance.

Yahel

-- 

3. hp ber-android...

4. Tanya Wipe & No Wipe

5. htc magic tdk bisa booting

6. Option menu, which way is better?

7. Screen Color depth