欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android實現(xiàn)網(wǎng)易云推薦歌單界面

 更新時間:2022年02月13日 16:12:53   作者:計蒙不吃魚  
大家好,本篇文章主要講的是Android實現(xiàn)網(wǎng)易云推薦歌單界面,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下

先來看看網(wǎng)易云APP的效果:

請?zhí)砑訄D片描述

前言

關(guān)于網(wǎng)易云音樂推薦歌單界面的實現(xiàn)

一、實現(xiàn)

1.自定義一個圓角圖片控件(也可直接使用第三方框架)

由于是一些簡單的繪制,就不一一介紹了,直接上代碼。

public class MellowImageView extends ImageView {
    private Paint paint;

    public MellowImageView(Context context) {
        super(context);
    }

    public MellowImageView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MellowImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        paint=new Paint();
    }
    /**
     * 繪制圓角矩形圖片
     * @author jimeng
     */
    @Override
    protected void onDraw(Canvas canvas) {
        Drawable drawable = getDrawable();
        if (null != drawable) {
            Bitmap bitmap = getBitmapFromDrawable(drawable);
            Bitmap b = getRoundBitmapByShader(bitmap,getWidth(),getHeight(), 20,0);
            final Rect rectSrc = new Rect(0, 0, b.getWidth(), b.getHeight());
            final Rect rectDest = new Rect(0,0,getWidth(),getHeight());

            canvas.drawBitmap(b, rectSrc, rectDest, paint);

        } else {
            super.onDraw(canvas);
        }
    }

    /**
     * 把圖片轉(zhuǎn)換成Bitmap
     * @param drawable
     * 資源圖片
     * @return 位圖
     */
    public static Bitmap getBitmapFromDrawable(Drawable drawable) {
        int width = drawable.getIntrinsicWidth();
        int height = drawable.getIntrinsicHeight();
        Bitmap bitmap = Bitmap.createBitmap(width, height, drawable
                .getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
                : Bitmap.Config.RGB_565);
        Canvas canvas = new Canvas(bitmap);
        drawable.draw(canvas);
        return bitmap;
    }

    public static Bitmap getRoundBitmapByShader(Bitmap bitmap, int outWidth, int outHeight, int radius, int boarder) {
        if (bitmap == null) {
            return null;
        }
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        float widthScale = outWidth * 1f / width;
        float heightScale = outHeight * 1f / height;

        Matrix matrix = new Matrix();
        matrix.setScale(widthScale, heightScale);
        //創(chuàng)建需要輸出的bitmap
        Bitmap desBitmap = Bitmap.createBitmap(outWidth, outHeight, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(desBitmap);
        Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
        //著色器
        BitmapShader bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
        //給著色器配置matrix
        bitmapShader.setLocalMatrix(matrix);
        paint.setShader(bitmapShader);
        //創(chuàng)建矩形區(qū)域并且預(yù)留出border
        RectF rect = new RectF(boarder, boarder, outWidth - boarder, outHeight - boarder);
        //把傳入的bitmap繪制到圓角矩形區(qū)域內(nèi)
        canvas.drawRoundRect(rect, radius, radius, paint);
        return desBitmap;
    }



}

效果圖如下:

請?zhí)砑訄D片描述

時間原因,一些簡單的細(xì)節(jié)沒有畫上去。

2.進(jìn)行布局?jǐn)[設(shè)

將整個布局放在HorizontalScrollView中使其可以左右滑動,以一個item為例。

<HorizontalScrollView
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    android:orientation="horizontal"
    >
 <LinearLayout
     android:layout_width="wrap_content"
     android:layout_height="match_parent"
     android:orientation="horizontal">
<!--     美化,并無其他作用-->
     <RelativeLayout
         android:layout_width="@dimen/jimeng_dp_16"
         android:layout_height="@dimen/jimeng_dp_135"/>

  
     <RelativeLayout
         android:layout_width="@dimen/jimeng_dp_130"
         android:layout_height="@dimen/jimeng_dp_135"
         >

         <TextView
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@id/like_icon2"
             android:layout_centerHorizontal="true"
             android:text="計蒙不吃魚"
             android:maxLines="1"
             android:ellipsize="end"
             android:textColor="@color/jimeng_black"
             android:textSize="12.0dip" />

         <com.shenzhen.jimeng.jmhnzsb.View.MellowImageView
             android:id="@+id/like_icon2"
             android:layout_width="120.0dip"
             android:layout_height="120.0dip"
             android:layout_centerHorizontal="true"
             android:scaleType="centerCrop"
             android:src="@drawable/yf1" />

     </RelativeLayout>
    
 </LinearLayout>

</HorizontalScrollView >

3.圖片切換動畫效果

博主使用的是ViewFlipper。
XML代碼如下

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ViewFlipper
        android:id="@+id/viewFlipper"
        android:layout_width="120.0dip"
        android:layout_height="120.0dip"
        android:flipInterval="3000"
        android:inAnimation="@anim/anim_marquee_in"
        android:outAnimation="@anim/anim_marquee_out" />
</RelativeLayout>

劃重點:兩個動畫文件,計蒙調(diào)試的將近30分鐘才調(diào)試成類似效果
anim_marquee_in:

<?xml version="1.0" encoding="utf-8"?>

    <set xmlns:android="http://schemas.android.com/apk/res/android">
        <translate
            android:duration="500"
            android:fromYDelta="120%p"
            android:toYDelta="0"/>
    <scale
        android:duration="500"
        android:fromXScale="0.8"
        android:fromYScale="0.8"
        android:toXScale="1"
        android:toYScale="1"
        android:pivotY="50%"
        android:pivotX="50%"/>
    </set>

anim_marquee_out:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="500"
        android:fromYDelta="0"
        android:toYDelta="-120%p"/>
    <scale
        android:duration="500"
        android:fromXScale="1"
        android:fromYScale="1"
        android:toXScale="0.8"
        android:toYScale="0.8"
        android:pivotY="50%"
        android:pivotX="50%">

    </scale>

</set

在Java文件中為ViewFlipper添加view:

    private ViewFlipper viewFlipper;
    //---------------------------------
    viewFlipper.removeAllViews();
    View view = View.inflate(getContext(), R.layout.home_rebroadcast_item, null);
    MellowImageView carouselImageView=view.findViewById(R.id.carousel_item_iv);
    View view1 = View.inflate(getContext(), R.layout.home_rebroadcast_item1, null);
    MellowImageView carouselImageView1=view.findViewById(R.id.carousel_item_iv);

    // 循環(huán)滾動圖片的點擊事件
    // iv.setOnClickListener(new ....);
    //添加view
    viewFlipper.addView(view);
    viewFlipper.addView(view1);

二、實現(xiàn)效果展示

請?zhí)砑訄D片描述

三、總結(jié)

效果其實比較好實現(xiàn),但是很多地方需要設(shè)置一些判斷。

到此這篇關(guān)于Android實現(xiàn)網(wǎng)易云推薦歌單界面的文章就介紹到這了,更多相關(guān)Android網(wǎng)易云歌單界面內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Android獲取、更改包名的小技巧分享(超實用)

    Android獲取、更改包名的小技巧分享(超實用)

    這篇文章主要給大家分享介紹了關(guān)于利用Android更改包名的一個小技巧,通過這個方法大家可以很方便的修改包名,再也不用為頻繁修改包名而感到頭疼,文中還給大家分享利一個android獲取手機(jī)所有應(yīng)用包名的方法,下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-12-12
  • Android中button點擊后字體的變色效果

    Android中button點擊后字體的變色效果

    button的點擊效果無疑是非常簡單的,接下來通過本文給大家介紹下如何添加button點擊的字體顏色變化效果,感興趣的朋友一起看看吧
    2016-10-10
  • Android Service服務(wù)不被停止詳解及實現(xiàn)

    Android Service服務(wù)不被停止詳解及實現(xiàn)

    這篇文章主要介紹了Android Service服務(wù)不被停止詳解及實現(xiàn)的相關(guān)資料,有很多應(yīng)用在設(shè)置運行中會被直接停止掉,這里就提供一個方法一直運行,需要的朋友可以參考下
    2016-11-11
  • 詳解Android布局優(yōu)化

    詳解Android布局優(yōu)化

    本篇文章給大家詳細(xì)分析了Android布局優(yōu)化的相關(guān)知識點以及注意事項,對此有需要的朋友可以參考學(xué)習(xí)下。
    2018-03-03
  • 如何快速創(chuàng)建Android模擬器

    如何快速創(chuàng)建Android模擬器

    這篇文章主要為大家詳細(xì)介紹了快速創(chuàng)建Android模擬器的方法,感興趣的小伙伴們可以參考一下
    2016-06-06
  • Android仿eleme點餐頁面二級聯(lián)動列表

    Android仿eleme點餐頁面二級聯(lián)動列表

    本站一直在點外賣,于是心血來潮就像仿餓了么做個站,接下來通過本文給大家介紹android 二級聯(lián)動列表,仿eleme點餐頁面的相關(guān)資料,需要的朋友可以參考下
    2016-10-10
  • Android開發(fā)之WebView組件的使用解析

    Android開發(fā)之WebView組件的使用解析

    WebView 類是 WebKit 模塊 Java 層的視圖類, 所有需要使用 Web 瀏覽功能的Android應(yīng)用程序都要創(chuàng)建該視圖對象顯示和處理請求的網(wǎng)絡(luò)資源,接下來將詳細(xì)介紹,需要了解的朋友可以參考下
    2012-12-12
  • Android Studio配置本地SDK的方法

    Android Studio配置本地SDK的方法

    這篇文章主要介紹了Android Studio配置本地SDK的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • android自定義gradle插件并且發(fā)布到本地倉庫詳細(xì)教程

    android自定義gradle插件并且發(fā)布到本地倉庫詳細(xì)教程

    這篇文章主要介紹了android自定義gradle插件并且發(fā)布到本地倉庫詳細(xì)教程的相關(guān)資料,需要的朋友可以參考下
    2023-07-07
  • 封裝的android監(jiān)聽手指左右滑動屏幕的事件類分享

    封裝的android監(jiān)聽手指左右滑動屏幕的事件類分享

    這篇文章主要介紹了封裝的android監(jiān)聽手指左右滑動屏幕的事件類分享,本文分別給出了簡單處理方法的代碼和封裝好的處理類代碼,需要的朋友可以參考下
    2015-05-05

最新評論