看了都会喜欢的:loading效果
介绍:
一个不错的loading加载效果,弹性收缩,效果不错,学习android动画的朋友可以下载来研究研究
本例子其实由SeekBar实现,由MetaballView,MetaballDebugView实现动画效果.
项目来自:http://www.itlanbao.com/code/20151209/10000/100683.html
当滑动到有一个位置的时候设置选中和未选中状态.
metaballView.setPaintMode();
debugMetaballView.setPaintMode();
设置SeekBar 的进度debugMetaballView.setMaxDistance(progress);
效果截图:


布局引入:
<RelativeLayout 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="#001d30"
android:clipChildren="false"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<com.dodola.animview.MetaballView
android:id="@+id/metaball"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<com.dodola.animview.MetaballDebugView
android:id="@+id/debug_metaball"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/metaball"
android:layout_alignRight="@+id/metaball"
android:layout_below="@+id/metaball"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/debug_metaball"
android:text="Debug test"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:clickable="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="最大间距"
android:textColor="@android:color/white" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:max="400" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="贝塞尔曲线角度"
android:textColor="@android:color/white" />
<SeekBar
android:id="@+id/seekBar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="200" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="贝塞尔曲线控制点长度比率"
android:textColor="@android:color/white" />
<SeekBar
android:id="@+id/seekBar3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="500" />
</LinearLayout>
</RelativeLayout>
主要代码如下:
package com.dodola.animview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ProgressBar;
import android.widget.SeekBar;
public class MainActivity extends AppCompatActivity implements SeekBar.OnSeekBarChangeListener {
private MetaballView metaballView;
private MetaballDebugView debugMetaballView;
private SeekBar seekBar, seekBar2, seekBar3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
metaballView = (MetaballView) this.findViewById(R.id.metaball);
debugMetaballView = (MetaballDebugView) findViewById(R.id.debug_metaball);
seekBar = (SeekBar) findViewById(R.id.seekBar);
seekBar2 = (SeekBar) findViewById(R.id.seekBar2);
seekBar3 = (SeekBar) findViewById(R.id.seekBar3);
seekBar.setOnSeekBarChangeListener(this);
seekBar2.setOnSeekBarChangeListener(this);
seekBar3.setOnSeekBarChangeListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_fill) {
metaballView.setPaintMode(1);
debugMetaballView.setPaintMode(1);
return true;
} else if (id == R.id.action_strock) {
metaballView.setPaintMode(0);
debugMetaballView.setPaintMode(0);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
switch (seekBar.getId()) {
case R.id.seekBar:
debugMetaballView.setMaxDistance(progress);
break;
case R.id.seekBar2:
debugMetaballView.setMv(progress / 100f);
break;
case R.id.seekBar3:
debugMetaballView.setHandleLenRate(progress / 100f);
break;
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
} 相关推荐
xfcyhades 2020-11-20
Michael 2020-11-03
业余架构师 2020-10-09
OuNuo0 2020-09-29
moses 2020-09-22
Angelia 2020-09-11
qinxu 2020-09-10
刘炳昭 2020-09-10
Nostalgiachild 2020-09-07
Nostalgiachild 2020-08-17
leavesC 2020-08-14
一青年 2020-08-13
AndroidAiStudy 2020-08-07
ydc0 2020-07-30
绿豆饼 2020-07-28