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 com.android.frameworks.coretests.R;
20 
21 import android.app.Activity;
22 import android.os.Bundle;
23 import android.widget.EditText;
24 import android.widget.TextView;
25 import android.widget.Button;
26 import android.view.View;
27 import android.graphics.Rect;
28 
29 public class RequestRectangleVisibleWithInternalScroll extends Activity {
30 
31     private int scrollYofBlob = 52;
32 
33     private TextView mTextBlob;
34     private Button mScrollToBlob;
35 
36 
getScrollYofBlob()37     public int getScrollYofBlob() {
38         return scrollYofBlob;
39     }
40 
41 
getTextBlob()42     public TextView getTextBlob() {
43         return mTextBlob;
44     }
45 
46 
getScrollToBlob()47     public Button getScrollToBlob() {
48         return mScrollToBlob;
49     }
50 
onCreate(Bundle icicle)51     protected void onCreate(Bundle icicle) {
52         super.onCreate(icicle);
53 
54         setContentView(R.layout.scroll_to_rect_with_internal_scroll);
55 
56         mTextBlob = findViewById(R.id.blob);
57         mTextBlob.scrollBy(0, scrollYofBlob);
58 
59 
60         mScrollToBlob = findViewById(R.id.scrollToBlob);
61         mScrollToBlob.setOnClickListener(new View.OnClickListener() {
62 
63             public void onClick(View v) {
64 
65                 // the rect we want to make visible is offset to match
66                 // the internal scroll
67                 Rect rect = new Rect();
68                 rect.set(0, 0, 0, mTextBlob.getHeight());
69                 rect.offset(0, mTextBlob.getScrollY());
70                 mTextBlob.requestRectangleOnScreen(rect);
71             }
72         });
73     }
74 
75 
76 }
77