I figured out a solution that should be easy to implement. This includes modifying the layout and activity inflating the layout ... see below:
Activity (QuickPlay.java):
public class QuickPlay extends Activity implements AnimationListener { private ImageView myImageView; private LinearLayout LL; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.quick_play_screen); myImageView = (ImageView) this.findViewById(R.id.Clip); LL = (LinearLayout) this.findViewById(R.id.QuickPlayClipLayout);
New LinearLayout (CustomLinearLayout.java):
public class CustomLinearLayout extends LinearLayout { private Context myContext; public CustomLinearLayout(Context context, AttributeSet attrs) { super(context, attrs); myContext = context; } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec+((int)myContext.getResources().getDimension(R.dimen.quickplay_offset))); } }
Layout (/res/layout/quick_play_screen.xml):
<?xml version="1.0" encoding="utf-8"?> <com.games.mygame.CustomLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/QuickPlayClipLayout"> <ImageView android:id="@+id/Clip" android:background="@drawable/clip" android:layout_width="fill_parent" android:layout_height="wrap_content"> </ImageView> </com.games.mygame.CustomLinearLayout>
Resource (/res/values/constants.xml):
<?xml version="1.0" encoding="utf-8"?> <resources> <dimen name="quickplay_offset">50dp</dimen> </resources>
Animation (/res/anim/slide_in_quickplay.xml):
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:fromYDelta="100%p" android:toYDelta="0" android:duration="1000"/> <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" /> </set>
Now the program does what I need. The entire layout starts from the screen below, slides in 1 second and comes to its senses, where the top of the layout is actually 50 pixels on top of the screen (i.e. LL.getTop() = -50 ), and the bottom of the layout is on the bottom screen (i.e. LL.getBottom() = 530 = 480 + 50 ).