最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android仿通話來電界面效果

 更新時間:2021年09月24日 09:32:14   作者:tracydragonlxy  
這篇文章主要為大家詳細(xì)介紹了Android仿通話來電界面效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

Android仿通話來電界面,供大家參考,具體內(nèi)容如下

簡介:開發(fā)中需要模擬來電時的通話界面,仿照來電界面實(shí)現(xiàn)來電時播放鈴聲,界面通過動畫模擬來電動效。

效果圖:

自定義圖片背景,圖片由小變大的動態(tài)效果。

shap_circle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <corners android:radius="65dp"/>
    <solid android:color="#31DE87"/>

</shape>

布局文件activity_my_call.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true"
    tools:context=".MyCall.MyCallActivity">

    <ImageView
        android:id="@+id/iv_bg"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"
        android:src="@mipmap/img1"/>

    <ImageView
        android:id="@+id/iv_head"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="60dp"
        android:src="@mipmap/header"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

    <TextView
        android:id="@+id/tv_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:text="+86-123-4567 8910"
        android:textSize="24sp"
        android:textStyle="bold"
        android:textColor="#fff"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@id/iv_head"/>

    <TextView
        android:id="@+id/tv_from"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:textColor="#fff"
        android:textSize="20sp"
        android:text="深圳市 中國移動來電"
        app:layout_constraintTop_toBottomOf="@id/tv_phone"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"/>

    <ImageView
        android:id="@+id/iv_hang_up"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:src="@mipmap/hang_up"
        android:layout_marginBottom="60dp"
        app:layout_constraintBottom_toTopOf="@id/iv_wave1"
        app:layout_constraintStart_toStartOf="@id/iv_wave1"
        app:layout_constraintEnd_toEndOf="@id/iv_wave1" />

    <ImageView
    android:id="@+id/iv_wave1"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:layout_marginBottom="200dp"
    android:background="@drawable/shape_circle"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"/>

    <ImageView
        android:id="@+id/iv_wave2"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:background="@drawable/shape_circle"
        app:layout_constraintTop_toTopOf="@id/iv_wave1"
        app:layout_constraintBottom_toBottomOf="@id/iv_wave1"
        app:layout_constraintStart_toStartOf="@id/iv_wave1"
        app:layout_constraintEnd_toEndOf="@id/iv_wave1"/>

    <ImageView
        android:id="@+id/iv_call"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:src="@mipmap/call_in"
        app:layout_constraintTop_toTopOf="@id/iv_wave1"
        app:layout_constraintBottom_toBottomOf="@id/iv_wave1"
        app:layout_constraintStart_toStartOf="@id/iv_wave1"
        app:layout_constraintEnd_toEndOf="@id/iv_wave1"/>

    <ImageView
        android:id="@+id/iv_answer"
        android:layout_width="64dp"
        android:layout_height="64dp"
        android:src="@mipmap/answer"
        android:layout_marginTop="60dp"
        app:layout_constraintStart_toStartOf="@id/iv_wave1"
        app:layout_constraintEnd_toEndOf="@id/iv_wave1"
        app:layout_constraintTop_toBottomOf="@id/iv_wave1"/>

</androidx.constraintlayout.widget.ConstraintLayout>

MyCallActivity.java

public class MyCallActivity extends AppCompatActivity {

    ImageView iv1, iv2;

    private MediaPlayer mMediaPlayer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_call);

        ImageView ivBg = findViewById(R.id.iv_bg);
        Glide.with(this)
                .load(R.mipmap.img2)
                .apply(RequestOptions.bitmapTransform(new BlurTransformation(25, 6)))
                .into(ivBg);

        iv1 = findViewById(R.id.iv_wave1);
        iv2 = findViewById(R.id.iv_wave2);

        mMediaPlayer = MediaPlayer.create(this,
                        RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_RINGTONE));
        mMediaPlayer.setLooping(true);
        playRingTone();

        setAnim1();

        setAnim2();
    }

    @Override
    protected void onPause() {
        super.onPause();
        iv1.clearAnimation();
        iv2.clearAnimation();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        stopRingTone();
    }

    public void playRingTone(){
        if (mMediaPlayer.isPlaying()) {
            return;
        }
        mMediaPlayer.start();
    }

    public void stopRingTone() {
        if (mMediaPlayer.isPlaying()) {
            mMediaPlayer.stop();
            mMediaPlayer.release();
        }
    }

    private void setAnim1() {
        AnimationSet as = new AnimationSet(true);
        //縮放動畫,以中心從原始放大到1.4倍
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 1.4f, 1.0f, 1.4f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        //漸變動畫
        AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.5f);
        scaleAnimation.setDuration(800);
        scaleAnimation.setRepeatCount(Animation.INFINITE);
        alphaAnimation.setRepeatCount(Animation.INFINITE);
        as.setDuration(800);
        as.addAnimation(scaleAnimation);
        as.addAnimation(alphaAnimation);
        iv1.startAnimation(as);
    }

    private void setAnim2() {
        AnimationSet as = new AnimationSet(true);
        //縮放動畫,以中心從1.4倍放大到1.8倍
        ScaleAnimation scaleAnimation = new ScaleAnimation(1.4f, 1.8f, 1.4f, 1.8f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f,
                ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
        //漸變動畫
        AlphaAnimation alphaAnimation = new AlphaAnimation(0.5f, 0.1f);
        scaleAnimation.setDuration(800);
        scaleAnimation.setRepeatCount(Animation.INFINITE);
        alphaAnimation.setRepeatCount(Animation.INFINITE);
        as.setDuration(800);
        as.addAnimation(scaleAnimation);
        as.addAnimation(alphaAnimation);
        iv2.startAnimation(as);
    }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android開發(fā)懸浮窗踩坑解決

    Android開發(fā)懸浮窗踩坑解決

    這篇文章主要為大家介紹了Android懸浮窗踩坑解決示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • Android WebView控件基本使用示例

    Android WebView控件基本使用示例

    大家好,本篇文章主要講的是Android WebView控件基本使用示例,感興趣的同學(xué)趕快來看一看吧,對你有幫助的話記得收藏一下,方便下次瀏覽
    2022-01-01
  • android 上傳aar到私有maven服務(wù)器的示例

    android 上傳aar到私有maven服務(wù)器的示例

    這篇文章主要介紹了android 上傳aar到私有maven服務(wù)器,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • Android項(xiàng)目開發(fā)之UI設(shè)計(jì)器

    Android項(xiàng)目開發(fā)之UI設(shè)計(jì)器

    這篇文章主要為大家詳細(xì)介紹了Android項(xiàng)目開發(fā)之UI設(shè)計(jì)器,具有一定的實(shí)用性和參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-06-06
  • Flutter異步操作實(shí)現(xiàn)流程詳解

    Flutter異步操作實(shí)現(xiàn)流程詳解

    在Flutter中,借助 FutureBuilder 組件和 StreamBuilder 組件,可以非常方便地完成異步操作,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-09-09
  • Android ScrollView嵌套橫向滑動控件時沖突問題

    Android ScrollView嵌套橫向滑動控件時沖突問題

    本篇文章主要介紹了Android ScrollView嵌套橫向滑動控件時沖突問題,具有一定的參考價(jià)值,有興趣的可以了解一下
    2017-08-08
  • Android Studio 3.6運(yùn)行模擬器時Emulator警告問題的解決方案

    Android Studio 3.6運(yùn)行模擬器時Emulator警告問題的解決方案

    這篇文章主要介紹了Android Studio 3.6運(yùn)行模擬器時Emulator警告問題的解決方案,本文給大家介紹的非常詳細(xì),對大家的工作或?qū)W習(xí)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-03-03
  • flutter底部彈出BottomSheet詳解

    flutter底部彈出BottomSheet詳解

    這篇文章主要為大家詳細(xì)介紹了flutter底部彈出BottomSheet,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • android 退出程序解決內(nèi)存釋放的問題

    android 退出程序解決內(nèi)存釋放的問題

    做Android項(xiàng)目的時候發(fā)現(xiàn)一個問題:當(dāng)應(yīng)用程序退出了,點(diǎn)擊"設(shè)置"查看應(yīng)用程序,界面顯示著可以點(diǎn)擊"強(qiáng)制關(guān)閉 由于這個問題我發(fā)現(xiàn)了一個更加嚴(yán)重的問題,那就是,在我應(yīng)用程序退出之后,系統(tǒng)并沒有釋放掉我應(yīng)用程序所占內(nèi)存
    2012-11-11
  • 淺談Android textview文字對齊換行的問題

    淺談Android textview文字對齊換行的問題

    下面小編就為大家分享一篇淺談Android textview文字對齊換行的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-01-01

最新評論

铁岭县| 新闻| 乌恰县| 辽中县| 平南县| 仲巴县| 怀来县| 宁陕县| 平泉县| 日喀则市| 阿拉尔市| 新源县| 广州市| 滨海县| 阿拉善左旗| 韩城市| 平乐县| 突泉县| 墨竹工卡县| 康定县| 凤冈县| 莱阳市| 集贤县| 得荣县| 阿尔山市| 达孜县| 凤山县| 崇明县| 富源县| 濮阳县| 青海省| 城口县| 沭阳县| 民勤县| 当涂县| 宕昌县| 舞阳县| 陆良县| 凉山| 平阳县| 临沂市|