2013-01-13 5 views
0

열 0은 빨간색 x 또는 녹색 확인 표시가있는 그림입니다. 테스트 목적으로, 나는 행 1에 대해서만 이미지를 넣었습니다. 아래 그림에서 알 수 있듯이, 빨간색 x 이미지는 길고 직사각형으로 뻗어 있습니다. 작은 정사각형 이미지가되고 싶습니다. layout_width 및 layout_height를 각각 50dp 또는 10dp로 설정 했더라도 이미지는 아래 표시된 것과 같아 보입니다. 아래 코드를 참조하십시오. 그림의 크기는 100x100 PNG 그림입니다.ImageView는 스트레칭되지 않아야합니다. - Android

내 질문은 왜 이미지가 펼쳐져 있고 어떻게 작은 정사각형 이미지로 만들 것인가입니다. 당신의 도움에 미리 감사드립니다!

Results.java

ImageView q1Image = (ImageView)findViewById(R.id.q1Image); 
q1Image.setScaleType(ImageView.ScaleType.FIT_CENTER); 

resultsmain.xml

<TableRow 
    android:id="@+id/row4" 
    android:layout_width="0dip" 
    android:layout_height="wrap_content" 
    android:stretchColumns="0,1,2,3" 
    android:layout_weight="1" > 

    <ImageView 
     android:id="@+id/q1Image" 
     android:layout_width="5dp" 
     android:layout_height="10dp" 
     android:layout_weight=".1" /> 

    <TextView 
     android:id="@+id/q1Question" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".5" 
     android:textSize="8sp" /> 

    <TextView 
     android:id="@+id/q1Answer" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".2" 
     android:textSize="8sp" 
     android:gravity="center_horizontal" /> 

    <TextView 
     android:id="@+id/q1Verse" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".2" 
     android:textSize="8sp" 
     android:gravity="center_horizontal" /> 
</TableRow> 

enter image description here

답변

0

이 시도 :

<TableRow 
    android:id="@+id/row4" 
    android:layout_width="0dip" 
    android:layout_height="wrap_content" 
    android:stretchColumns="0,1,2,3" 
    android:weightSum="1" > 

    <ImageView 
     android:id="@+id/q1Image" 
     android:layout_width="5dp" 
     android:layout_height="10dp" 
     android:layout_weight=".1" 
     /> 

    <TextView 
     android:id="@+id/q1Question" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".5" 
     android:textSize="8sp" /> 

    <TextView 
     android:id="@+id/q1Answer" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".2" 
     android:textSize="8sp" 
     android:gravity="center_horizontal" /> 

    <TextView 
     android:id="@+id/q1Verse" 
     android:layout_width="0dip" 
     android:layout_height="wrap_content" 
     android:layout_weight=".2" 
     android:textSize="8sp" 
     android:gravity="center_horizontal" /> 
</TableRow> 
+0

야 @Appu, 위 코드에 대한 코드를 변경했습니다. 코드를 정확하게 보여주기 위해 개회사를 편집했습니다. 결과는 여전히 동일합니다. 무엇보다도 붉은 색 x가 이번에는 약간 넓어 질 수 있습니다. 결과는 여전히 동일합니다. 다른 제안? – Matt

관련 문제