0
내 앱에서는 JSON에서 이미지를 가져 와서 갤러리에 표시합니다. 각 이미지를 클릭하면 전체 활동으로 확장되며 정상적으로 보입니다. Pic one삼성 은하에서 이미지가 매우 작게 보임 S7
하지만 Galaxy S7 Edge에서 테스트했을 때 개별 이미지가 작아 보였습니다. Nougat을 사용하면 그 이미지가 작아 보입니다.
어떻게이 문제를 해결할 수 있습니다.
메신저 게시 내 코드
public class Displaydemo extends FragmentActivity {
static int NUM_ITEMS = 3;
static int pos ;
Button Img_Sel;
ProgressDialog pDialog;
public static String sel_img;
ImageFragmentPagerAdapter imageFragmentPagerAdapter;
ViewPager viewPager;
public static RequestQueue mRequestQueue;
public static ImageLoader mImageLoader;
public static NetworkImageView niv1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.displaydemo);
NUM_ITEMS= getIntent().getIntExtra("count",0);
pos=getIntent().getIntExtra("pos", 0);
getImageLoader();
Img_Sel=(Button)findViewById(R.id.Img_select);
imageFragmentPagerAdapter = new ImageFragmentPagerAdapter(getSupportFragmentManager());
viewPager = (ViewPager) findViewById(R.id.pagerdemo);
viewPager.setAdapter(imageFragmentPagerAdapter);
viewPager.setCurrentItem(pos);
}
public static class ImageFragmentPagerAdapter extends FragmentPagerAdapter {
public static int p=0;
public ImageFragmentPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public int getCount() {
return NUM_ITEMS;
}
@Override
public Fragment getItem(int position) {
p=position;
SwipeFragment fragment = new SwipeFragment();
return SwipeFragment.newInstance(p);
}
}
public static class SwipeFragment extends Fragment {
public static NetworkImageView imgNetWorkView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View swipeView = inflater.inflate(R.layout.swipe_fragment, container, false);
Bundle bundle = getArguments();
imgNetWorkView = (NetworkImageView) swipeView.findViewById(R.id.imgNetwork);
int position = bundle.getInt("position");
final String imgResId= Datas.imageIds[position];
Toast.makeText(getActivity(),imgResId,Toast.LENGTH_LONG).show();
imgNetWorkView.setImageUrl(imgResId, mImageLoader);
Displaydemo.sel_img=""+position;
String imgsel = imgResId;
imgNetWorkView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), GalleryActivity.class);
Bundle args = new Bundle();
String ur = null;
ur =imgResId;
args.putString("URL", ur);
intent.putExtras(args);
startActivity(intent);
}
});
return swipeView;
}
static SwipeFragment newInstance(int position) {
SwipeFragment swipeFragment = new SwipeFragment();
Bundle bundle = new Bundle();
bundle.putInt("position", position);
swipeFragment.setArguments(bundle);
return swipeFragment;
}
}
XML ViewPager
에 이미지를 표시 ImageView
에 대한
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:gravity="center">
<android.support.v4.view.ViewPager
android:id="@+id/pagerdemo"
android:layout_width="fill_parent"
android:scaleType="fitCenter"
android:background="@android:color/transparent"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
사용 : android : scaleType = "fitXY" –