2014-09-22 78 views
0

image我做了一个android活动,我已经把scrollView,现在我想,当我打开活动,它应该滚动到20%它应该向下滚动后,我已经尝试了这么多的链接和refrences,但我没有做到这一点,任何人都可以请帮我我怎么做到这一点,我的XML代码如下scrollview,我已经把图像,我希望scrollview显示已经在活动启动时滚动到某个固定高度。如何显示scrollView已经滚动20%的活动启动

main.xml中

<ScrollView 
     android:id="@+id/scr_profile" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" 
     android:scrollY="200dp" 
     android:scrollbars="none" > 

     <RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" > 
...... 

</ScrollView> 
+0

如果可能的话提供截图 – Panther 2014-09-22 06:50:39

+0

@ Panther-请稍候,,感谢您的回复 – user3820044 2014-09-22 06:51:26

+0

解释你所尝试过的。你说你“试过这么多的链接”,所以你一定试过了ScrollView#scrollBy。为什么它不适合你? – Marius 2014-09-22 06:51:49

回答

0

你有没有尝试Runnable接口?

 final ScrollView scroll = (ScrollView) this.findViewById(R.id.scr_profile); 

    scroll.post(new Runnable() { 
     @Override 
     public void run() { 
      scroll.scrollTo(200, 200); 
     } 
    }); 

这对我无效。

+0

其实,我已经试过这个befoe你的答案,它为我工作..谢谢亲爱的。 – user3820044 2014-09-22 07:35:03

0

你可以这样做:

<ScrollView 
    android:id="@+id/scr_profile" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fillViewport="true" 
    android:scrollY="200dp" 
    android:scrollbars="none" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 
    <TextView 
     android:id="@+id/firstname" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content"> 


    <requestFocus /> //i put here. you can put on the view where you want to scroll 
    </TextView> 

......

相关问题