Iam using below code in xml file and adding child views programmatically by using textview but i need to go specific position(suppose in every textview iam adding number start from 1 then i want to go 5th position textview from total of 10 textviews) on the view using scrollview.I knew the method to scroll but i dont know how to calculate the x y cooardinates from this layout.Please give guidance.
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:scrollbars="vertical"
android:id="@+id/agenda_scroll"
>
<LinearLayout android:id="@+id/inner_layout"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
</LinearLayout>
</ScrollView>
Suppost my code is like this
ScrollView scview = (ScrollView)findViewById(R.id.Scl);
LinearLayout eventLayout = (LinearLayout) findViewById(R.id.inner_layout);
TextView txtView = new TextView(cx);
txtView.setText("1");
eventLayout.addView(txtview);
TextView txtView = new TextView(cx);
txtView.setText("2");
eventLayout.addView(txtview);
TextView txtView = new TextView(cx);
txtView.setText("3");
eventLayout.addView(txtview);
TextView txtView = new TextView(cx);
txtView.setText("4");
eventLayout.addView(txtview);
TextView txtView = new TextView(cx);
txtView.setText("5");
int y = txtview.getTop();
Log.d(TAG,"YAxis"+y);//returning 0
eventLayout.addView(txtview);
TextView txtView = new TextView(cx);
txtView.setText("6");
eventLayout.addView(txtview);
.........
scview .scrollTo(0,y);///here positions giving (0,0)