0

I'm trying to put a shadow (just a regular ImageView) right below the screen, this way when the user drag the view up, it will be able to see the shadow.

How should I setup the margin, etc.

My current setup is:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginBottom="-10dp"
android:minHeight="200dp" >

<EditText
    android:id="@+id/edit_content"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="top"
    android:layout_marginBottom="10dp"
    android:background="#00000000"
    android:ems="10"
    android:gravity="top"
    android:inputType="textMultiLine"
    android:lineSpacingExtra="3sp"
    android:padding="20dp" />


<ImageView
    android:layout_width="match_parent"
    android:layout_height="10dp"
    android:padding="10dp"
    android:layout_alignParentBottom="true"
    android:src="@drawable/some_shadow"/>

Doing it this way the ImageView is on the bottom of the screen, but what I need is to have it right below the screen by its height. (So it's top is aligned with screen's bottom).

Any advice?

Edison
  • 5,961
  • 4
  • 23
  • 39

2 Answers2

1

Do not do android:layout_marginBottom="-10dp" here, it will overflow your view.

What you can do is to put it in the views next to your screen and listen for the scrolling.

0

How about this,

Paint mShadow = new Paint(); 
// radius=10, y-offset=2, color=black 
mShadow.setShadowLayer(10.0f, 0.0f, 2.0f, 0xFF000000); 
// in onDraw(Canvas) 
canvas.drawBitmap(bitmap, 0.0f, 0.0f, mShadow);

or

look at this https://stackoverflow.com/a/4405209/1143977

Community
  • 1
  • 1
VendettaDroid
  • 3,131
  • 2
  • 28
  • 41
  • The problem with this is that I am not dealing with a single background, I have a background for the parent already, this shadow, unfortunately, is not part of it ... :( – Edison Sep 05 '12 at 20:07
  • In that case, why don't you set your imageview drawable to be null and instead set shadow image to be background of imageview. May be try this out. – VendettaDroid Sep 05 '12 at 20:10
  • Um, let me see if I can combine the two backgrounds, maybe that will work. Do you know how I can place a view that is larger than the parent on the screen? e.g. width=parent_width+specific_extra – Edison Sep 05 '12 at 20:15
  • It would be similar to a horizontal scroll view, except the other views are shown only if you are dragging. might have to do more than just shadows. – Edison Sep 05 '12 at 20:44