2011-10-04 4 views
0

나는 PizzaOverview가 있습니다.그림이 너무 커서 모든보기를 볼 수 없습니다.

enter image description here

는 XML : 사진이 너무 큰

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 
    <TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="" android:id="@+id/pizza_tv" android:gravity="center_horizontal" android:textSize="15pt"></TextView> 
    <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/pizza_iv" android:src="@drawable/icon" android:layout_gravity="center_horizontal"></ImageView> 
    <RatingBar android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/pizza_rb" android:layout_gravity="center_horizontal"></RatingBar> 
    <TextView android:layout_height="wrap_content" android:text="" android:id="@+id/pizza_date" android:gravity="center|center_horizontal" android:layout_width="fill_parent"></TextView> 

<RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
     <Button android:text="close" android:layout_height="wrap_content" android:id="@+id/pizza_bt" android:layout_alignParentBottom="true" android:layout_width="fill_parent"></Button> 
    </RelativeLayout> 
    </LinearLayout> 

경우 날짜가 보이지 않습니다.

enter image description here

답변

0

추가 스크롤 뷰 레이아웃에 또는 이미지 뷰

의 크기를 수정하는 것은

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
> 
<ScrollView 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
> 
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:text="" android:id="@+id/pizza_tv" android:gravity="center_horizontal" android:textSize="15pt"></TextView> 
<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/pizza_iv" android:src="@drawable/icon" android:layout_gravity="center_horizontal"></ImageView> 
<RatingBar android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/pizza_rb" android:layout_gravity="center_horizontal"></RatingBar> 
<TextView android:layout_height="wrap_content" android:text="" android:id="@+id/pizza_date" android:gravity="center|center_horizontal" android:layout_width="fill_parent"></TextView> 

<RelativeLayout android:id="@+id/relativeLayout2" android:layout_width="fill_parent" android:layout_height="fill_parent"> 
    <Button android:text="close" android:layout_height="wrap_content" android:id="@+id/pizza_bt" android:layout_alignParentBottom="true" android:layout_width="fill_parent"></Button> 
</RelativeLayout> 
</LinearLayout> 
</ScrollView> 
</LinearLayout> 
0

당신이 활동에 제공 한 이미지가이 있는지 확인 레이아웃에 스크롤 뷰를 추가 올바른 해상도와 크기. 또한 별도의 화면 크기 범주에 대해 별도의 레이아웃이 있는지 확인하십시오.

레이아웃 및 다양한 화면 크기 관리에 대한 자세한 내용은 Android 설명서의 this 섹션을 참조하십시오. 필요한 기본 사항을 알려줍니다.

0

등급 표시 줄과 그 아래에있는 텍스트를 RelativeLayout에 넣을 수 있습니다. Button의 높이와 동일한 RelativeLayoutmarginBottom을 입력하십시오. 그런 다음 텍스트를 놓고 ID를주고 android:layout_alignParentBottom="true"을 추가하십시오. 이미지의 heightfill_parent으로 설정하고 android:layout:below="id_of_text" 속성을 추가하십시오.

0

다른 답변 상태에서 화면을 스크롤 가능하게 만들 수 있습니다. 하지만 콘텐츠가 동적 인 경우 (그리고 장치에 따라 콘텐츠가 항상 동적이라고 말할 수는 있습니다) ImageView의 경계가 올바르게 설정되어 있는지 확인해야합니다. 소스 코드에서

당신은 :

<ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/pizza_iv" android:src="@drawable/icon" android:layout_gravity="center_horizontal"></ImageView> 

당신은 대신이 있어야합니다

<ImageView android:layout_height="0dp" 
    android:weight="1" 
    android:layout_width="match_parent" 
    android:id="@+id/pizza_iv" 
    android:src="@drawable/icon" 
    android:layout_gravity="center_horizontal" 
    android:scaleType="centerInside"/> 

weight의 추가 속성은보기가 경계에서 설정 한 방향에 따라 사용 가능한 공간을 채우기 할 것 LinearLayout. 이 방향에 따른 다른 뷰의 가중치에 따라 달라집니다 (이 경우 다른 뷰에는 가중치가 없으므로 고정 뷰의 가장자리까지 모든 공간을 채 웁니다).

scaleType="centerInside"의 추가 속성을 사용하면 경계 상자를 중첩 할 정도로 커지지 않고 제안한 경계의 가운데에 이미지를 표시 할 수 있습니다 (화면 너비와 사용 가능한 모든 공간).

ImageView을 사용하는 경우 ImageView은 이미지의 경계 컨테이너라는 점에 유의해야합니다. 가능한 크거나 작을 수 있지만 이미지를 배치 할 위치를 UI에 알리는 메커니즘 일뿐입니다. scaleType 속성은이 경계 계수기 내에 이미지를 배치하는 방법을 말하기 위해 사용하는 속성입니다. ImageView에서 "wrap_content"을 사용하면 효과가 없으며 나중에 설계를 할 때 문제가 발생할 수 있습니다 (특히 다른 장치를 고려할 때).

관련 문제