1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.widget.scroll; 18 19 import android.app.Activity; 20 import android.graphics.Rect; 21 import android.os.Bundle; 22 import android.view.View; 23 import android.widget.Button; 24 import android.widget.TextView; 25 26 import com.android.frameworks.coretests.R; 27 28 public class RequestRectangleVisibleWithInternalScroll extends Activity { 29 30 private int scrollYofBlob = 52; 31 32 private TextView mTextBlob; 33 private Button mScrollToBlob; 34 35 getScrollYofBlob()36 public int getScrollYofBlob() { 37 return scrollYofBlob; 38 } 39 40 getTextBlob()41 public TextView getTextBlob() { 42 return mTextBlob; 43 } 44 45 getScrollToBlob()46 public Button getScrollToBlob() { 47 return mScrollToBlob; 48 } 49 onCreate(Bundle icicle)50 protected void onCreate(Bundle icicle) { 51 super.onCreate(icicle); 52 53 setContentView(R.layout.scroll_to_rect_with_internal_scroll); 54 55 mTextBlob = findViewById(R.id.blob); 56 mTextBlob.scrollBy(0, scrollYofBlob); 57 58 59 mScrollToBlob = findViewById(R.id.scrollToBlob); 60 mScrollToBlob.setOnClickListener(new View.OnClickListener() { 61 62 public void onClick(View v) { 63 64 // the rect we want to make visible is offset to match 65 // the internal scroll 66 Rect rect = new Rect(); 67 rect.set(0, 0, 0, mTextBlob.getHeight()); 68 rect.offset(0, mTextBlob.getScrollY()); 69 mTextBlob.requestRectangleOnScreen(rect); 70 } 71 }); 72 } 73 74 75 } 76