android如何在進入有scrollview的頁面時滑動條置頂

時間 2021-12-19 01:32:43

1樓:小傻

android 在進入有scrollview的頁面時滑動條置頂,可以使用scrollto方法可以調整view的顯示位置。在需要的地方呼叫以下方法即可。scroll表示外層的view,inner表示內層的view,其餘內容都在inner裡。

例項如下:

public static void scrolltobottom(final view scroll, final view inner)

int offset = inner.getmeasuredheight() - scroll.getheight();

if (offset < 0)

scroll.scrollto(0, offset);//將滾動條放到頂部

}});}

2樓:

scrollview.scrollto(0,0);

activity裡初始化後新增該**讓滾動條滑動到頂部下面的解決方式可能會更好:

進入頁面後,顯示位置下移,主要是因為焦點問題. 所以在它的上一層布局 加

android:focusableintouchmode="true" 就能解決你所遇到的問題

或者加在根布局也可以

3樓:匿名使用者

跪了,本來就置頂的。。。

4樓:

怎麼解決的,我也是這問題,指點下哦

5樓:匿名使用者

在最外面的布局也就是父布局加上屬性:

android:focusableintouchmode="true"

android怎麼獲取scrollview滑動時與布局頂部的距離

6樓:匿名使用者

直接使用 android.view.view.

getscrolly() 就可以了 這個是獲得 當前 滑動位置 距離 scrollview 頂部的距離 類似的 listview 也有這個方法

android中如何在textview中加入

貪戀邇的香吻 具體 如下 android中的textview,本身就支援部分的html格式標籤。這其中包括常用的字型大小顏色設定,文字鏈結等。使用起來也比較方便,只需要使用html類轉換一下即可。比如 textview.settext html.fromhtml str 然而,有一種場合,預設支援的...

如何在android開發中activity之間資料傳遞

好程式設計師 用intent在activity之間傳遞資料,需要注意三個方法 1.startactivityforresult intent intent,int requestcode 2.setresult int resultcode,intent data 3.onactivityresul...

如何在android開發使用ACTION

可以自定義乙個actionbar導航欄的。其實就相當於不用系統的actionbar就像是自己定義的titlebar一樣 你可以共享下面的 string sharebody here is the share content body intent sharingintent new intent a...

如何在eclipse中新增android ADT

方法如下 開啟eclipse,進入工作介面後點選選單欄的help選擇install new software.進入後點選新增 add 按鈕。eclipse adt開發android程式的模式,目前已經被google淘汰了,推行使用android studio,更快的響應速度。android 官網之前...

如何在bios裡設定u盤啟動,如何進入bios設定u盤啟動為優先啟動項?

方法 1 開機按f2或del鍵進入cmos,用方向鍵選擇boot選項,按回車鍵開啟boot device priority選項。2 用 號鍵,將u盤設定為第一啟動即可。3 也可以插入u盤啟動盤後,開機按f12直接進入驅動器選單,選擇u盤進入pe系統。開機或重啟時,在進入windows前按f2進入bi...