:
내가 fill_parent하는 이미지 뷰의 레이아웃 높이를 필요로하지만 대신 스케일링의 같은 크기를 유지하기 위해 이미지가 필요, 여기에 내 현재 코드입니다
레이아웃의 전체 코드를 제공하지 않았기 때문에 몇 가지 가정을 할 것입니다 ... 스케일링없이 스프라이트의 높이를 화면의 높이로 설정하는 것에 대해 이야기하고 있습니까?
화면 크기 (즉, 루트 레이아웃 항목)와 스프라이트가 다를 수 있습니다. 나는 당신이로 레이아웃을 선언 생각 ... :
:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="?gameBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btTap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="14dp"
android:layout_marginTop="350dp"
android:background="@drawable/tap"
android:visibility="visible" />
<Button
android:id="@+id/btCellR1C1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="490dp"
android:layout_marginTop="155dp"
android:background="@drawable/cell_red" />
내가 대처했던 유일한 것은, 이러한 방법으로 장치의 해상도에 따라 내 스프라이트의 확장이었다
public static void scaleView(View view, int top, int left, int width,
int height) {
top = Math.round(top * scaleY);
left = Math.round(left * scaleX);
width = Math.round(width * scaleX);
height = Math.round(height * scaleY);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.height = height;
params.width = width;
params.topMargin = top;
params.leftMargin = left;
view.setLayoutParams(params);
view.setSoundEffectsEnabled(false);
}
우리에게 서지
을 당신에게 도움이
안부 더 많은 세부 사항을 제공하십시오