當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.setTranslationX方法代碼示例

本文整理匯總了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();
        }
    });
}
 
開發者ID:braulio94,項目名稱:Quadro,代碼行數:22,代碼來源:ExploreActivity.java

示例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);

}
 
開發者ID:alaskalinuxuser,項目名稱:apps_small,代碼行數:19,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:alaskalinuxuser,項目名稱:apps_small,代碼行數:12,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:codeestX,項目名稱:ECardFlow,代碼行數:15,代碼來源:MoveAnimMode.java


注:本文中的android.widget.ImageView.setTranslationX方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。