本文整理汇总了Java中android.widget.ImageView.setTranslationX方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setTranslationX方法的具体用法?Java ImageView.setTranslationX怎么用?Java ImageView.setTranslationX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setTranslationX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explore);
iv = (ImageView) findViewById(R.id.search);
text = (EditText) findViewById(R.id.text);
searchToBar = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_search_to_bar);
barToSearch = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.anim_bar_to_search);
interp = AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in);
duration = getResources().getInteger(R.integer.duration_bar);
// iv is sized to hold the search+bar so when only showing the search icon, translate the
// whole view left by half the difference to keep it centered
offset = -71f * (int) getResources().getDisplayMetrics().scaledDensity;
iv.setTranslationX(offset);
iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
animate();
}
});
}
示例2: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// My nifty animation!
// Declare the image view to use.
ImageView aklu = (ImageView)findViewById(R.id.aklu);
// Set it to be visable.
aklu.setVisibility(View.VISIBLE);
// Initially set that image off screen.
aklu.setTranslationX(-1000f);
// Bring image on screen and then off the screen again!
aklu.animate().translationXBy(2000f).setDuration(3000);
// And just to be sure, let's make it invisable again.
aklu.setVisibility(View.INVISIBLE);
}
示例3: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Note that this image view is set off screen from the app start.
// Define the image view to use.
ImageView firstPic = (ImageView) findViewById(R.id.imageView2);
// Set that view off screen.
firstPic.setTranslationX(1000f);
}
示例4: transformPage
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public void transformPage(ImageView ivBg, float position, int direction) {
ivBg.setScaleX(mScale);
ivBg.setScaleY(mScale);
float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2);
int lastPosition = Math.round(position);
float mFraction;
if (lastPosition % 2 == 0) {
mFraction = -1 * (float) Math.sin(Math.PI * position);
} else {
mFraction = (float) Math.sin(Math.PI * position);
}
ivBg.setTranslationX(totalMoveWidth * mFraction);
}