垂直自動滾動問題(第一行固定,其餘行自動滾動)有人知道怎麼實現嗎?

============問題描述============html


你們好,小弟想作一個公告牌的Android程序,想實現以下效果:第一行(標題行)固定,其餘行(詳細內容)自動垂直滾動,應該怎麼作呢?網上搜了相關資料,都沒有這方面的完整例子


網上找到一個能夠垂直滾動的代碼如附件AutoScroll(下載地址:http://download.csdn.net/detail/tc310/7887641),這個能夠垂直滾動,可是確實全部內容都滾動,沒法把第一行(標題)固定顯示。

我把佈局文件改爲以下,發現運行報錯,沒法運行起來。有沒有人知道怎麼解決這個問題啊?謝謝

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical" >



<TextView

        android:id="@+id/tvTitle"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:gravity="center"

        android:text="這裏顯示標題" /> 



    <TableLayout

        android:id="@+id/table1"

        android:layout_width="fill_parent"

        android:layout_height="wrap_content"        

        >



        <TableRow>                 

            <com.tony.autoscroll.AutoScrollView

                android:id="@+id/auto_scrollview"

                android:layout_width="fill_parent"

                android:layout_height="700dp" >



                <LinearLayout

                    android:layout_width="fill_parent"

                    android:layout_height="fill_parent"

                    android:orientation="vertical" >

                     

                    <ImageView

                        android:layout_width="fill_parent"

                        android:layout_height="40dip"

                        android:scaleType="fitXY"

                        android:src="@drawable/bg2" />



                    <TextView

                        android:layout_width="fill_parent"

                        android:layout_height="wrap_content"

                        android:text="一、對財政收支的審計監督\n二、對金融機構的審計監督\n三、對事業組織的審計監督\n四、對企業的審計監督\n五、對政府投資建設項目的審計監督\n六、對社會保障等資金基金的審計監督\n七、對外資項目的審計監督\n八、經濟責任審計監督\n九、其餘法律、行政法規規定事項的審計監督\n十、專項審計調查\n十一、對內部審計機構的指導監督\n十二、對社會審計機構審計質量的檢查\n"

                        android:textSize="36pt" />



                    <ImageView

                        android:layout_width="fill_parent"

                        android:layout_height="40dip"

                        android:scaleType="fitXY"

                        android:src="@drawable/bg1" />



                    <TextView

                        android:layout_width="fill_parent"

                        android:layout_height="wrap_content"

                        android:text="一、對財政收支的審計監督\n二、對金融機構的審計監督\n三、對事業組織的審計監督\n四、對企業的審計監督\n五、對政府投資建設項目的審計監督\n六、對社會保障等資金基金的審計監督\n七、對外資項目的審計監督\n八、經濟責任審計監督\n九、其餘法律、行政法規規定事項的審計監督\n十、專項審計調查\n十一、對內部審計機構的指導監督\n十二、對社會審計機構審計質量的檢查\n" />

                </LinearLayout>

            </com.tony.autoscroll.AutoScrollView>

        </TableRow>

    </TableLayout>



</LinearLayout>

============解決方案1============android


LIstview和socallview這些東西不是提供了麼,,,

============解決方案2============佈局


你第一行是標題,內容應該和滾動的那些行不同的吧?那你能夠把標題單獨用一個TextView來作呀,而後滾動的就是ListView,這樣滾動的時候絲絕不影響標題,由於它倆分開了。佈局也很簡單,就是一個垂直的LinearLayout中先放TextView再放ListView,注意高度不要設成充滿父控件,否則會擋住。固然用其餘佈局也能夠。

============解決方案3============.net


http://www.cnblogs.com/vaiyanzi/archive/2011/12/06/2277791.html

============解決方案4============線程


引用 6 樓 tc310 的回覆:
Quote: 引用 3 樓 OrthocenterChocolate 的回覆:
你第一行是標題,內容應該和滾動的那些行不同的吧?那你能夠把標題單獨用一個TextView來作呀,而後滾動的就是ListView,這樣滾動的時候絲絕不影響標題,由於它倆分開了。佈局也很簡單,就是一個垂直的LinearLayout中先放TextView再放ListView,注意高度不要設成充滿父控件,否則會擋住。固然用其餘佈局也能夠。
ListView能實現垂直自動滾動嗎?能否給個例子呢。 我是想作一個公告板的程序,第一行是標題(如:XXXX通知),下面是具體內容,當具體內容信息不少時,要自動垂直滾動顯示(循環)
額,你能夠這樣,listview有個方法smoothScrollToPosition,能夠滾動到你指定的位置,那麼你想要的自動滾動,可讓它先滾到1,再滾到2,...,以此類推,用一個線程來滾,當滾到最後一項時,再滾到0從新開始。
相關文章
相關標籤/搜索