1
나는 게임을 짜기 시작했으나 화면 해상도와 밀도와 혼동스러워졌다.와이드 스크린을 854 와이드 스크린에 맞게 조정하기
800 픽셀 너비의 이미지가 있고 드로어 블 mdpi 폴더에 추가되었습니다. 854 픽셀의 화면에는 54 픽셀 간격이 있습니다.
이미지를 화면에 맞추는 가장 좋은 방법은 무엇입니까?
감사
나는 게임을 짜기 시작했으나 화면 해상도와 밀도와 혼동스러워졌다.와이드 스크린을 854 와이드 스크린에 맞게 조정하기
800 픽셀 너비의 이미지가 있고 드로어 블 mdpi 폴더에 추가되었습니다. 854 픽셀의 화면에는 54 픽셀 간격이 있습니다.
이미지를 화면에 맞추는 가장 좋은 방법은 무엇입니까?
감사
는 프로젝트에 follwing을 클래스를 추가하고이
보기처럼 레이아웃을 변경
<my.package.name.AspectRatioImageView
android:layout_centerHorizontal="true"
android:src="@drawable/my_image"
android:id="@+id/my_image"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:adjustViewBounds="true" />
클래스
package my.package.name;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
/**
* ImageView which scales an image while maintaining
* the original image aspect ratio
*
*/
public class AspectRatioImageView extends ImageView {
/**
* Constructor
*
* @param Context context
*/
public AspectRatioImageView(Context context) {
super(context);
}
/**
* Constructor
*
* @param Context context
* @param AttributeSet attrs
*/
public AspectRatioImageView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Constructor
*
* @param Context context
* @param AttributeSet attrs
* @param int defStyle
*/
public AspectRatioImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
/**
* Called from the view renderer.
* Scales the image according to its aspect ratio.
*/
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = width * getDrawable().getIntrinsicHeight()/getDrawable().getIntrinsicWidth();
setMeasuredDimension(width, height);
}
}
당신은 무엇을 programm를 지정할 수 있습니다 이 언어/문맥은 무엇입니까? – Mikey
@Mikey - 구글은 안드로이드에 대해 말한다. – Attila