Android 为什么HorizontalScrollView不能在HTCDesire 2.2中滚动,而只能在模拟器上滚动?
我在视图中使用的是Android 为什么HorizontalScrollView不能在HTCDesire 2.2中滚动,而只能在模拟器上滚动?,android,android-widget,android-layout,Android,Android Widget,Android Layout,我在视图中使用的是HorizentalScrollView。我在运行时添加TextView。我使用horView.smoothScrollTo(x,y);它适用于模拟器。但是它在HTCDesire 2.2上没有滚动?有什么想法吗?这是我的密码 horView.smoothScrollTo(num, 0); <HorizontalScrollView android:id="@+id/cate_head" android:scrollbars="none" and
HorizentalScrollView
。我在运行时添加TextView
。我使用horView.smoothScrollTo(x,y)
;它适用于模拟器。但是它在HTCDesire 2.2上没有滚动?有什么想法吗?这是我的密码
horView.smoothScrollTo(num, 0);
<HorizontalScrollView
android:id="@+id/cate_head"
android:scrollbars="none"
android:foregroundGravity="fill_horizontal"
android:layout_width="fill_parent"
android:paddingTop="6dip"
android:background="@drawable/slider_background"
android:focusable="true"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/cate_head_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip">
</LinearLayout>
</HorizontalScrollView>
horView.smoothScrollTo(num,0);
最后我找到了解决方案。我在创建时调用了smoothScrollTo(x,y)(我还能把它放在哪里?)问题是在初始化时没有找到大小或长度(但不应该是,因为我已经把所有数据都放在了里面)。
因此,以50秒的延迟调用postdaly()。它对我有用。给你。我把它放在onCreate()的末尾;
b其他人可以用面糊溶液吗
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
horView.smoothScrollTo((scrollAmount), 0);
}
}, 50);
您可以使用View.post来避免依赖于时间
horView.post(new Runnable() {
public void run() {
horView.smoothScrollTo((scrollAmount), 0);
}
});
这将在视图连接到屏幕后立即执行