안드로이드 개발 질문/답변
(글 수 45,052)
이미지를 둥그렇게 늘어놓고 싶은데요
지금 계속 자료조사하면서 찾은건 겔러리와 플리퍼로 구현하는게 있는거같은데
이미지를 반원형으로 둥글게 배치하려고 하는데요
맨 끝은 작게 그 앞쪽은 조금 크게. 맨앞의 이미지 한개는 제일 크게 배치하고 싶은데
갤러리나 플리퍼에 이미지를 넣을때 각각의 크기를 지정할 수 있나요??
겔러리는 일자로 배치했는데 크기나 위치는 지정 못해봤고
플리퍼는 아예 이미지를 겔러리처럼 배치도 못한형편입니다.
개발할 시간이 충분치 못해서 다 테스트를 할수 없는데요..
일단 두개 중에 이미지를 둥글게 배치하고 크기도 각각 지정할수 있는게 있나요??
지금 계속 자료조사하면서 찾은건 겔러리와 플리퍼로 구현하는게 있는거같은데
이미지를 반원형으로 둥글게 배치하려고 하는데요
맨 끝은 작게 그 앞쪽은 조금 크게. 맨앞의 이미지 한개는 제일 크게 배치하고 싶은데
갤러리나 플리퍼에 이미지를 넣을때 각각의 크기를 지정할 수 있나요??
겔러리는 일자로 배치했는데 크기나 위치는 지정 못해봤고
플리퍼는 아예 이미지를 겔러리처럼 배치도 못한형편입니다.
개발할 시간이 충분치 못해서 다 테스트를 할수 없는데요..
일단 두개 중에 이미지를 둥글게 배치하고 크기도 각각 지정할수 있는게 있나요??




둥글게...는 크기를 조절해서 표현이 가능합니다.
그래서 크기를 조절하는 부분만 구현해봤습니다.
이건 APIDemo의 소스를 수정한 넘입니다.
package com.example.android.apis.view; import com.example.android.apis.R; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.animation.AnimationUtils; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.Gallery.LayoutParams; import android.widget.ImageSwitcher; import android.widget.ImageView; import android.widget.ViewSwitcher; public class ImageSwitcher1 extends Activity implements AdapterView.OnItemSelectedListener, ViewSwitcher.ViewFactory { public int selectedIndex = -1; ImageAdapter ia; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.image_switcher_1); mSwitcher = (ImageSwitcher) findViewById(R.id.switcher); mSwitcher.setFactory(this); mSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_in)); mSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out)); ia = new ImageAdapter(this); Gallery g = (Gallery) findViewById(R.id.gallery); g.setCallbackDuringFling(true); g.setAdapter(ia); g.setOnItemSelectedListener(this); } public void onItemSelected(AdapterView parent, View v, int position, long id) { mSwitcher.setImageResource(mImageIds[position]); ia.setSelectedPosition(position); ia.notifyDataSetChanged(); } public void onNothingSelected(AdapterView parent) { } public View makeView() { ImageView i = new ImageView(this); i.setBackgroundColor(0xFF000000); i.setScaleType(ImageView.ScaleType.FIT_CENTER); i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); return i; } private ImageSwitcher mSwitcher; public class ImageAdapter extends BaseAdapter { int mSelectedPosition = -1; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return mThumbIds.length; } public Object getItem(int position) { return position; } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mThumbIds[position]); imageView.setAdjustViewBounds(false); if(position == mSelectedPosition){ imageView.setLayoutParams(new Gallery.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); }else if(Math.abs(position-mSelectedPosition)==1 && mSelectedPosition!=-1){ imageView.setLayoutParams(new Gallery.LayoutParams( 20, 20)); }else if(mSelectedPosition!=-1){ imageView.setLayoutParams(new Gallery.LayoutParams( 10, 10)); }else{ imageView.setLayoutParams(new Gallery.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); } imageView.setBackgroundResource(R.drawable.picture_frame); return imageView; } private Context mContext; public void setSelectedPosition(int p){ mSelectedPosition = p; } } private Integer[] mThumbIds = { R.drawable.sample_thumb_0, R.drawable.sample_thumb_1, R.drawable.sample_thumb_2, R.drawable.sample_thumb_3, R.drawable.sample_thumb_4, R.drawable.sample_thumb_5, R.drawable.sample_thumb_6, R.drawable.sample_thumb_7}; private Integer[] mImageIds = { R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, R.drawable.sample_3, R.drawable.sample_4, R.drawable.sample_5, R.drawable.sample_6, R.drawable.sample_7}; }