内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Android仿微信雷達(dá)掃描效果的實(shí)現(xiàn)方法

本文主要給大家介紹的是關(guān)于Android實(shí)現(xiàn)微信雷達(dá)掃描效果的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面來看看詳細(xì)的介紹:

網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、小程序制作、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了鐵鋒免費(fèi)建站歡迎大家使用!

廢話不多說 先上圖(用AS錄制的 轉(zhuǎn)換工具不是很好 所以看得效果不是很好)

效果圖

Android仿微信雷達(dá)掃描效果的實(shí)現(xiàn)方法

示例代碼

Activity 代碼

public class ShapeDrawableActivity extends AppCompatActivity {
 private ImageView ivLightbeam;

 private ObjectAnimator radarScanAnim; // 掃描動(dòng)畫

 private int width;
 private int height;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  setContentView(R.layout.activity_shape_drawable);
  ivLightbeam = (ImageView) findViewById(R.id.ivLightbeam);
 }


 @Override
 protected void onResume() {
  super.onResume();
  startScan();
 }

 @Override
 public void onWindowFocusChanged(boolean hasFocus) {
  super.onWindowFocusChanged(hasFocus);
  if (height == 0 || width == 0) {   //獲取屏幕長、寬
   width = ScreenUtils.getScreenWidth(this);
   height = ScreenUtils.getScreenHeight(this);   //根據(jù)屏幕長、寬計(jì)算掃描圓的直徑
   int diameter = (int) Math.sqrt(Math.pow(height, 2) + Math.pow(width, 2));   //修改光束的大小,使光束可以掃描到整個(gè)屏幕
   FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(diameter, diameter);
   ivLightbeam.setLayoutParams(layoutParams);   //將掃描光束的中心移至屏幕內(nèi)容中心
   int offsetX = (width - diameter) / 2;
   int offsetY = (height - diameter) / 2 + ScreenUtils.getStatusHeight(this) / 2;
   ivLightbeam.setX(offsetX);
   ivLightbeam.setY(offsetY);
  }
 }

 @Override
 protected void onPause() {
  super.onPause();
  stopScan();
 } // 開始掃描

 private void startScan() {
  radarScanAnim = ObjectAnimator.ofFloat(ivLightbeam, "rotation", 0f, 360f);
  radarScanAnim.setDuration(2000); //2秒掃描一圈
  radarScanAnim.setInterpolator(new LinearInterpolator());
  radarScanAnim.setRepeatCount(ObjectAnimator.INFINITE);//循環(huán)掃描

  ivLightbeam.setVisibility(View.VISIBLE);
  radarScanAnim.start();
 } // 停止掃描

 private void stopScan() {
  ivLightbeam.setVisibility(View.GONE);
  radarScanAnim.end();
 }
}

Activity 布局文件

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="#FA000000"
 android:clipToPadding="false"
 android:fitsSystemWindows="true">

 <ImageView
  android:id="@+id/ivWave"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:layout_margin="5dp"
  android:src="@drawable/wave" />

 <ImageView
  android:id="@+id/ivLightbeam"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:src="@drawable/light_beam" />

</FrameLayout>

繪制掃描光束

<shape
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:shape="oval">

 <size
  android:width="500dp"
  android:height="500dp" />

 <gradient
  android:endColor="#AAAAAAAA"
  android:startColor="#00000000"
  android:type="sweep"
  />
</shape>

繪制雷達(dá)波紋

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
 <item>
  <!--最外層圓圈-->
  <shape android:shape="oval">
   <solid android:color="#10FFFFFF" />
   <size
    android:width="600dp"
    android:height="600dp" />
   <stroke
    android:color="#10B8B8B8"
    android:dashWidth="1dp" />
  </shape>
 </item>

 <item
  android:bottom="100dp"
  android:left="100dp"
  android:right="100dp"
  android:top="100dp">
  <!--最中間層圓圈-->
  <shape android:shape="oval">
   <solid android:color="#1CFFFFFF" />
   <stroke
    android:color="#1CB8B8B8"
    android:dashWidth="1dp" />
  </shape>
 </item>

 <item
  android:bottom="200dp"
  android:left="200dp"
  android:right="200dp"
  android:top="200dp">

  <!--最中心圓圈-->
  <shape android:shape="oval">
   <solid android:color="#2CFFFFFF" />
   <stroke
    android:color="#2CB8B8B8"
    android:dashWidth="1dp" />
  </shape>
 </item>
</layer-list>

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對創(chuàng)新互聯(lián)的支持。

分享名稱:Android仿微信雷達(dá)掃描效果的實(shí)現(xiàn)方法
標(biāo)題URL:http://www.rwnh.cn/article20/jiscco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、微信小程序App設(shè)計(jì)、企業(yè)建站、云服務(wù)器

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都app開發(fā)公司
锦州市| 苍山县| 石棉县| 景宁| 高青县| 漳平市| 霸州市| 安宁市| 阿拉善盟| 北辰区| 贵德县| 永平县| 祁连县| 酉阳| 新乡县| 博湖县| 改则县| 左云县| 府谷县| 秦安县| 潜山县| 湖口县| 玉树县| 哈密市| 通州区| 莱州市| 临夏市| 上饶县| 东乡县| 肇州县| 滦南县| 五大连池市| 大宁县| 沭阳县| 古交市| 阜城县| 克东县| 顺平县| 阿坝| 游戏| 闽侯县|