本文整理匯總了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);
}