2011-04-24 3 views
1

사진 만세! 사진을 배경에 지정할 때와 그렇지 않은 경우의 모습은 다음과 같습니다.Android - 배경 이미지가 스트레치되지 않도록 설정합니다.보기를 할당했습니다.

enter image description here

enter image description here

나는 매우 이미지가 테이블보다 큰 경우는 최고 TableView을 스트레칭하지 할 수 싶습니다. XML에서 볼 수 있듯이 테이블의 배경을위한 약간의 여분의 공간을 이미 제공하기 위해 빈 "뷰"를 포함 시켰습니다. ScaleType을 사용하여 엉망으로 만들려고했으나 세척이 필요했습니다.

레이아웃에 맞게 BG를 늘리려면 어떻게해야합니까? 나는 "사용자 xxx는 WVGA보다 작은 화면"을 정상적으로 처리하려고 노력하고 있습니다. 분명히 은혜가 부족합니다. 그 모든 중요한 경우

<TableLayout 
android:id="@+id/widget29" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:scaleType="fitXY" 
android:background="@drawable/minetownx480" 
> 
<View 
android:id="@+id/blankSpace" 
android:layout_width="fill_parent" 
android:layout_height="60dip" /> 

<TableRow android:id="@+id/widget40" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal"> 
    <TextView android:id="@+id/moneyText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Money: $$$$$$$$$" /> 
    <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/savingsText" android:gravity="right" android:text="Savings: $$$$$$$" android:layout_weight="3" android:textSize="12sp"/> 
</TableRow> 

<TableRow android:id="@+id/widget41" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal"> 
    <TextView android:id="@+id/wagonText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Wagon Space: XXX/XXX" /> 
    <TextView android:id="@+id/loanText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Loans: $$$$$$$$" android:gravity="right" android:layout_weight="3" android:textSize="12sp"/> 
</TableRow> 

<TableRow android:id="@+id/widget42" android:layout_width="fill_parent" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" > 
    <TextView android:id="@+id/daysText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Days Left: XX/XX" /> 
    <TextView android:id="@+id/armedText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Unarmed!" android:gravity="right" android:layout_weight="3" /> 
</TableRow> 
</TableLayout> 

TableLayout을은, 루트있는 LinearLayout의 첫 번째 요소입니다.

편집 : 이미지를 지정하기 전에 tableLayout의 X 및 Y 공간을 측정 할 수있는 방법을 알고 있다면 프로그래밍 방식으로 배정하여 할당 할 수 있습니다. 누군가 알고 있다면 어느 솔루션이 좋을까요?

답변

5

FrameLayout을 사용하여 두 개의 레이어 (즉, 내부에 두 개의보기 추가)를 만들 것입니다. 첫 번째는 ImageView이고 두 번째 테이블, 즉 상위 테이블이 테이블입니다. 이 방법으로 나는 이미지 스케일링을 제어하기 위해 테이블에 의존하지 않겠지 만 ImageView에서 독립적 일 것입니다. 이미지 뷰는 이미지를 '배경'으로 보이지 않고 소스로 보이기 때문에 더 쉽게 조작 할 수 있습니다.

+1

우수. 이것을 사용하여 구현했고 작동 중입니다. frameLayout이 어떻게 작동했는지 전혀 알지 못했습니다. 이것은 큰 설명이었습니다. – Eric

관련 문제