解决 显然你需要在相应的drawable-xhdpi等中使用片段drawable,而不是在drawable中。
我已经编写了一个带有三个片段的ViewPager,它们可以在LG G2,索尼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
}
}
我开始怀疑三星在他们的框架中有一些邪恶的问题。
解决
我在代码中重新调整了png的大小,而不是xml。
由于 / Gekn