直播系統程式碼,點選產生動畫效果並移動的特效
直播系統程式碼,點選產生動畫效果並移動的特效
實現方式
go TranslateAnimation translateAnimation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, -1, TranslateAnimation.RELATIVE_TO_SELF, 0, //0代表控制元件本身的位置 TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0); translateAnimation.setDuration(900); mViewReward.startAnimation(translateAnimation);
dmeo
```go <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android=" xmlns:app=" xmlns:tools=" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <androidx.constraintlayout.widget.ConstraintLayout app:layout_constraintLeft_toLeftOf="parent" android:id="@+id/reward_view" app:layout_constraintBottom_toTopOf="@id/reward" android:layout_marginBottom="100dp" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageView android:id="@+id/left_image" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent" android:layout_width="60dp" android:layout_height="60dp"/> <TextView android:id="@+id/tv" app:layout_constraintLeft_toRightOf="@id/left_image" app:layout_constraintTop_toTopOf="@id/left_image" app:layout_constraintBottom_toBottomOf="@id/left_image" android:layout_marginLeft="10dp" android:text="穿雲箭" android:textSize="14sp" android:textColor="#000000" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <ImageView android:id="@+id/right_image" app:layout_constraintLeft_toRightOf="@id/tv" app:layout_constraintTop_toTopOf="parent" android:layout_marginLeft="10dp" android:layout_width="60dp" android:layout_height="60dp"/> <TextView android:id="@+id/number" android:gravity="center" android:textSize="30sp" android:textColor="#FF5722" app:layout_constraintLeft_toRightOf="@id/right_image" app:layout_constraintTop_toTopOf="parent" android:text="x90" app:layout_constraintBottom_toBottomOf="parent" android:layout_width="60dp" android:layout_height="0dp"/> </androidx.constraintlayout.widget.ConstraintLayout> <Button android:id="@+id/reward" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" android:layout_width="match_parent" android:layout_height="wrap_content"/> </androidx.constraintlayout.widget.ConstraintLayout> public class MainActivity extends AppCompatActivity implements View.OnClickListener { private ImageView mImageLeft; private TextView mTv; private ImageView mImageRight; private TextView mNumber; private Button mReward; private ConstraintLayout mViewReward; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); } private void initView() { mImageLeft = (ImageView) findViewById(R.id.left_image); mTv = (TextView) findViewById(R.id.tv); mImageRight = (ImageView) findViewById(R.id.right_image); mNumber = (TextView) findViewById(R.id.number); mReward = (Button) findViewById(R.id.reward); mReward.setOnClickListener(this); mViewReward = (ConstraintLayout) findViewById(R.id.reward_view); Glide.with(this).load("https://avatar.csdnimg.cn/E/C/F/1_weixin_45680654_1609595020.jpg") .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(mImageLeft); Glide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fww4.sinaimg.cn%2Flarge%2F9150e4e5ly1fhhjs6mu89j20hs0hsqdk.jpg&refer=http%3A%2F%2F) .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(mImageRight); } private CountDownTimer countDownTimer = new CountDownTimer(3000,1000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { TranslateAnimation translateAnimation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, -1, //0代表控制元件本身的位置 TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0); translateAnimation.setDuration(900); mViewReward.startAnimation(translateAnimation); new Handler().postDelayed(new Runnable() { @Override public void run() { mViewReward.setVisibility(View.GONE); } },800); } }; @Override public void onClick(View v) { switch (v.getId()) { case R.id.reward: // TODO 21/08/25 Random ra =new Random(); int i = ra.nextInt(101 - 10) + 10; mNumber.setText("x"+i); mViewReward.setVisibility(View.VISIBLE); TranslateAnimation translateAnimation = new TranslateAnimation( TranslateAnimation.RELATIVE_TO_SELF, -1, TranslateAnimation.RELATIVE_TO_SELF, 0, //0代表控制元件本身的位置 TranslateAnimation.RELATIVE_TO_SELF, 0, TranslateAnimation.RELATIVE_TO_SELF, 0); translateAnimation.setDuration(900); mViewReward.startAnimation(translateAnimation); countDownTimer.start(); break; default: break; } } @Override protected void onDestroy() { if (countDownTimer!=null){ countDownTimer.cancel(); } super.onDestroy(); }
以上就是 直播系統程式碼,點選產生動畫效果並移動的特效,更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2849706/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 成品直播原始碼推薦,js點選讓視窗抖動動畫效果原始碼JS動畫
- 愛奇藝直播-打造高效的特效資源生產體系特效
- canvas實現點選產生放射性效果程式碼例項Canvas
- 成品直播原始碼,點選滑動切換效果原始碼
- canvas 點選產生放射性效果Canvas
- 高階UI特效仿直播點贊效果—一個優美炫酷的點贊動畫UI特效動畫
- 直播系統程式碼,點選選擇欄,彈出各個選項
- CSS去除移動端點選時元素產生的背景色CSS
- 移動端動畫特效開啟加速動畫特效
- app直播系統原始碼,點選生成條形碼APP原始碼
- 直播app系統原始碼,圖片Loading旋轉動畫效果APP原始碼動畫
- 線上直播系統原始碼,使用ValueAnimator實現view放大縮小動畫效果原始碼View動畫
- 服裝生產管理軟體鞋帽生產系統的優點
- 直播系統原始碼,點選滾動的輪播圖自動跳轉到相應頁原始碼
- 直播系統程式碼,選擇分類時,顯示更多下拉框效果的內容
- 點選左右箭頭可以移動選項例項程式碼
- 直播系統程式碼,給標題欄新增陰影效果和圓角效果
- 直播系統平臺搭建,大屏倒數計時動畫效果動畫
- 直播app系統原始碼,canvas上放置按鈕並實現點選之後全屏顯示APP原始碼Canvas
- 直播系統原始碼,雲朵左右移動迴圈動畫實現原始碼動畫
- winphone系統a、input標籤被點選時產生的半透明灰色背景
- JavaScript點選投票效果程式碼例項JavaScript
- 移動端點選事件延遲的誕生消亡史事件
- css3控制多個背景圖片移動形成動畫效果程式碼例項CSSS3動畫
- 直播系統程式碼,Android自定義View實現呼吸燈效果AndroidView
- jQuery點選滑出層效果程式碼例項jQuery
- 線上直播系統原始碼,取CTreeCtrl控制元件選中節點的文字原始碼控制元件
- jQuery 動畫效果程式碼例項jQuery動畫
- 移動端點選彈出提示視窗程式碼例項
- 直播原始碼網站,點選分類調起選單欄並彈出原始碼網站
- 新舊系統更替產生的資料遷移問題
- 移動端div塊拖動效果程式碼例項
- CSS3 單選框動畫特效CSSS3動畫特效
- jquery外掛——點選交換元素位置(帶動畫效果)jQuery動畫
- 直播系統app原始碼,滑塊效果、slider用法APP原始碼IDE
- 產品的生態系統
- 直播特效的實現原理與難點特效
- 點選返回頂部程式碼具有緩衝效果