Baby_Bonnie 2013-02-05 04:57 采纳率: 96.4%
浏览 1946

如何让顶端的项目凸显出来

我在程序中设置的一个scroll view,但是当运行代码时,我发现顶端的一些项目隐藏了看不见。我想从顶端开始显示这个 scroll view 。需求帮忙解决。
我用的下面的代码:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" 
    android:scrollbars="none"
    android:scrollX="0px">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >

         <ImageView
            android:id="@+id/img_logo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/logo"
            android:focusable="true" 
            android:layout_marginTop="1dip" />

        <ImageView
            android:id="@+id/img_logo"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/jvdbanner" />

        <ListView
            android:id="@+id/main_list"
            android:layout_width="fill_parent"
            android:layout_height="279dip"
            android:background="#84CFE7"
            android:cacheColorHint="#00000000"
            android:divider="#000000"
            android:dividerHeight="1dip"
            android:focusable="false"
            android:fadingEdge="none"
            android:scrollbars="none" />

        <View
            android:layout_width="fill_parent"
            android:layout_height="2dip"
            android:layout_marginTop="5dip"
            android:background="#ffffff" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="10dip"
            android:text="Copyright @ 2012- JVD Properties, Inc."
            android:textColor="#ffffff"
            android:textSize="13sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="5dip"
            android:text="All Rights Reserved."
            android:textColor="#ffffff"
            android:textSize="13sp" />
    </LinearLayout>
</ScrollView>

</LinearLayout>
  • 写回答

1条回答

  • 问答小助手 2013-02-05 06:50
    关注

    试下这个方法,应该能帮的上你。

    final ScrollView main = (ScrollView) findViewById(R.id.scrollView1);
    
    main.post(new Runnable() {
    
        public void run() {
    
            main.scrollTo(0,0);
        }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?