實習(xí)筆記2

retrofit

在安卓中顯示gif圖片

使用WebView

<WebView
    android:id="@+id/runWebView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true" />
runWebView.loadDataWithBaseURL(null,
"<html>
    <body bgcolor='#f3f3f3'>
        <div align=center>
            <IMG src='file:///android_asset/run.gif'/>
        </div>
    </body>
</html>", "text/html", "UTF-8",null);

實現(xiàn)底部狀態(tài)欄

使用recyclerview + gridlayoutmanager

    val rc_btm_navi = findViewById<RecyclerView>(R.id.rc_btm_navi)
    rc_btm_navi.layoutManager = GridLayoutManager(this,1).apply {
        orientation = GridLayoutManager.HORIZONTAL
    }
    rc_btm_navi.adapter = navi_adapter()

adaper中獲取屏幕寬度,創(chuàng)建view時設(shè)置view的寬度

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): view_holder {
    val view: View =
        LayoutInflater.from(parent.context)
            .inflate(
                R.layout.item_navi,
                parent,
                false
            )
    view.layoutParams.width = getScreenWidth(activity) / navi_arr.size
    return view_holder(view)
}

自定義下拉刷新(沒學(xué)會)

  • TRANSLUCENT 半透明

rectF類

Rect F holds four float coordinates for a rectangle . The rectangle
is represented by the coordinates of its 4 edges ( left , top , right
bottom ). These fields can be accessed directly . Use width () and
height () to retrieve the rectangle ’ s width and height . Note :
most methods do not check to see that the coordinates are sorted
correctly ( i . e . left <= right and top <= bottom ).

ViewFlipper(翻轉(zhuǎn)視圖)

  • 就是首次安裝軟件后的功能介紹頁面

使用

導(dǎo)入圖片

    <ViewFlipper
        android:id="@+id/vflp_help"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:inAnimation="@anim/right_in"
        android:outAnimation="@anim/right_out"
        android:flipInterval="3000">

        <include layout="@layout/page_help_one" />
        <include layout="@layout/page_help_two" />
        <include layout="@layout/page_help_three" />
        <include layout="@layout/page_help_four" />
        <!--此處為靜態(tài)導(dǎo)入-->

    </ViewFlipper>
//動態(tài)導(dǎo)入
for(int i = 0;i < resId.length;i++){
    vflp_help.addView(getImageView(resId[i]));
}
private ImageView getImageView(int resId){
    ImageView img = new ImageView(this);
    img.setBackgroundResource(resId);
    return img;
}

翻動

手動翻動

  • 自定義一個GestureListener
  • 創(chuàng)建一個GestureDetector
  • 重寫activity的onTouchEvent
private class MyGestureListener extends GestureDetector.SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float v, float v1) {
        if(e1.getX() - e2.getX() > MIN_MOVE){
            vflp_help.setInAnimation(mContext,R.anim.right_in);
            vflp_help.setOutAnimation(mContext, R.anim.right_out);
            vflp_help.showNext();
        }else if(e2.getX() - e1.getX() > MIN_MOVE){
            vflp_help.setInAnimation(mContext,R.anim.left_in);
            vflp_help.setOutAnimation(mContext, R.anim.left_out);
            vflp_help.showPrevious();
        }
        return true;
    }
}
@Override
public boolean onTouchEvent(MotionEvent event) {
    return mDetector.onTouchEvent(event);
}
//自動翻動
vflp_help.startFlipping();

fragment中實現(xiàn)觸摸事件

參考

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末襟衰,一起剝皮案震驚了整個濱河市延都,隨后出現(xiàn)的幾起案子狈网,更是在濱河造成了極大的恐慌魄宏,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,470評論 6 501
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件赤屋,死亡現(xiàn)場離奇詭異吨瞎,居然都是意外死亡痹兜,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,393評論 3 392
  • 文/潘曉璐 我一進(jìn)店門颤诀,熙熙樓的掌柜王于貴愁眉苦臉地迎上來字旭,“玉大人,你說我怎么就攤上這事崖叫∫糯荆” “怎么了?”我有些...
    開封第一講書人閱讀 162,577評論 0 353
  • 文/不壞的土叔 我叫張陵心傀,是天一觀的道長屈暗。 經(jīng)常有香客問我,道長脂男,這世上最難降的妖魔是什么养叛? 我笑而不...
    開封第一講書人閱讀 58,176評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮宰翅,結(jié)果婚禮上弃甥,老公的妹妹穿的比我還像新娘。我一直安慰自己汁讼,他們只是感情好淆攻,可當(dāng)我...
    茶點故事閱讀 67,189評論 6 388
  • 文/花漫 我一把揭開白布阔墩。 她就那樣靜靜地躺著,像睡著了一般瓶珊。 火紅的嫁衣襯著肌膚如雪啸箫。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,155評論 1 299
  • 那天伞芹,我揣著相機與錄音忘苛,去河邊找鬼。 笑死唱较,一個胖子當(dāng)著我的面吹牛柑土,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播绊汹,決...
    沈念sama閱讀 40,041評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼扮宠!你這毒婦竟也來了西乖?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,903評論 0 274
  • 序言:老撾萬榮一對情侶失蹤坛增,失蹤者是張志新(化名)和其女友劉穎获雕,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體收捣,經(jīng)...
    沈念sama閱讀 45,319評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡届案,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,539評論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了罢艾。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片楣颠。...
    茶點故事閱讀 39,703評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖咐蚯,靈堂內(nèi)的尸體忽然破棺而出童漩,到底是詐尸還是另有隱情,我是刑警寧澤春锋,帶...
    沈念sama閱讀 35,417評論 5 343
  • 正文 年R本政府宣布矫膨,位于F島的核電站,受9級特大地震影響期奔,放射性物質(zhì)發(fā)生泄漏侧馅。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,013評論 3 325
  • 文/蒙蒙 一呐萌、第九天 我趴在偏房一處隱蔽的房頂上張望馁痴。 院中可真熱鬧,春花似錦搁胆、人聲如沸弥搞。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,664評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽攀例。三九已至船逮,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間粤铭,已是汗流浹背挖胃。 一陣腳步聲響...
    開封第一講書人閱讀 32,818評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留梆惯,地道東北人酱鸭。 一個月前我還...
    沈念sama閱讀 47,711評論 2 368
  • 正文 我出身青樓,卻偏偏與公主長得像垛吗,于是被迫代替她去往敵國和親凹髓。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,601評論 2 353

推薦閱讀更多精彩內(nèi)容