這期內(nèi)容當中小編將會給大家?guī)碛嘘P如何在Android中利用ScrollView實現(xiàn)一個頂部懸停效果,文章內(nèi)容豐富且以專業(yè)的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設、高性價比邵陽網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式邵陽網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設找我們,業(yè)務覆蓋邵陽地區(qū)。費用合理售后完善,十載實體公司更值得信賴。原理:
原理其實很簡單就是對view的gone和visible,寫兩個相同的要置頂?shù)膙iew,一個設置為gone,一個為visible,當可見的view超出屏幕范圍的時候,將不可以的view設置為visible,不可見的view 與scrollview要同級,這樣滑動的時候不會影響到view的位置。
直接上代碼
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <com.lanmai.ObservableScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollview" android:layout_width="match_parent" android:layout_height="match_parent" > <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!-- 中間就是填充的view就不寫了--> <!--指定要置頂?shù)膙iew--> <TextView android:id="@+id/specific_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_red_dark" android:gravity="center" android:text="text" android:textSize="40sp"/> <TextView android:layout_width="match_parent" android:layout_height="200dp" android:background="@android:color/darker_gray" android:gravity="center" android:text="text" android:textSize="40sp"/> </LinearLayout> </RelativeLayout> </com.lanmai.ObservableScrollView> <!--指定要置頂?shù)南嗤膙iew visibility設置為gone --> <TextView android:id="@+id/specific_text_view_gone" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/holo_red_dark" android:gravity="center" android:text="text" android:textSize="40sp" android:visibility="gone"/> </RelativeLayout>
本文標題:如何在Android中利用ScrollView實現(xiàn)一個頂部懸停效果-創(chuàng)新互聯(lián)
網(wǎng)站路徑:http://muchs.cn/article8/coidip.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信公眾號、服務器托管、品牌網(wǎng)站設計、做網(wǎng)站、手機網(wǎng)站建設、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容