已解决显然你需要在各自的drawable-xhdpi等中有片段drawables而不是drawable。
我用三个片段编写了一个 ViewPager,它们在 LG G2、Sony Xperis S、Nexus4 和 5 上完美运行。但在三星 S4 上,左/右滑动不可能没有大延迟,我们已经在 4 个不同的 S4 上进行了测试,结果相同.
public class ViewPagerMainActivity extends FragmentActivity {
PageIndicator mIndicator;
int mViewPager;
private AutoScrollViewPager viewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.viewpager_layout);
ViewPagerMyPagerAdapter pageAdapter = new ViewPagerMyPagerAdapter(getSupportFragmentManager());
viewPager = (AutoScrollViewPager)findViewById(R.id.pager);
viewPager.setAdapter(pageAdapter);
CirclePageIndicator indicator = (CirclePageIndicator)findViewById(R.id.indicator);
mIndicator = indicator;
indicator.setViewPager(viewPager);
final float density = getResources().getDisplayMetrics().density;
indicator.setBackgroundColor(0xFFFFFFFF);
indicator.setRadius(5 * density);
indicator.setPageColor(0x00000000);
indicator.setFillColor(0xFFFFFFFF);
indicator.setStrokeColor(0xFFDE7900);
indicator.setStrokeWidth(2 * density);
viewPager.setInterval(3000);
viewPager.startAutoScroll();
viewPager.setScrollDurationFactor(12);
viewPager.setCycle(true);
TextView accept = (TextView)findViewById(R.id.textView3);
TextView notNow = (TextView)findViewById(R.id.textView2);
TextView img = (TextView) findViewById(R.id.terms);
img.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent("android.intent.action.VIEW",
Uri.parse("http://www.123on.com/legal"));
startActivity(browserIntent);
}
});
accept.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ActivityMain.contactPermission = true;
Logging.log("viewPager:"+ActivityMain.contactPermission);
ActivityMain.mActivityMainHandler.saveParams();
if (!ActivityMain.userVerifyFlag){ // user didn't verify phone number
finish();
ActivityMain.verifyPhoneNumber();
} else {
Logging.log("error: with verify flag true without permission true.");
}
}
});
notNow.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
protected void onPause() {
super.onPause();
viewPager.stopAutoScroll();
}
@Override
protected void onResume() {
super.onResume();
viewPager.startAutoScroll();
}
@Override
protected void onDestroy() {
super.onDestroy();
}
}
和
public class ViewPagerMyPagerAdapter extends FragmentPagerAdapter implements OnPageChangeListener {
private List<Fragment> fragments;
public ViewPagerMyPagerAdapter(FragmentManager fm) {
super(fm);
this.fragments = new ArrayList<Fragment>();
fragments.add(new ViewPagerFragmentOne());
fragments.add(new ViewPagerFragmentTwo());
fragments.add(new ViewPagerFragmentThree());
}
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}
@Override
public int getCount() {
return fragments.size();
}
@Override
public void onPageScrollStateChanged(int arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
// TODO Auto-generated method stub
}
@Override
public void onPageSelected(int arg0) {
// TODO Auto-generated method stub
}
}
我开始怀疑三星在他们的框架中存在一些严重的问题。
解决了
我用代码而不是 xml 重新调整了 png 的大小。
谢谢/Gekn