2011-02-15 6 views
0

Hy!그림의 크기를 조정하는 방법은 무엇입니까?

나는보기에 두 개의 그림과 buttom에 단추가 있습니다.

Screenshot

XML :

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical"> 
    <TextView android:layout_height="wrap_content" android:id="@+id/mainscreen" android:layout_width="fill_parent" android:text="Selected Channel" android:gravity="center" android:layout_alignParentTop="true"></TextView> 
    <ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView> 
    <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/mainscreen_state" android:layout_above="@+id/mainscreen_btchange"></TextView> 
    <ImageView android:layout_width="wrap_content" android:layout_centerHorizontal="true" android:layout_height="wrap_content" android:id="@+id/ImageAd" android:layout_gravity="center" android:layout_below="@+id/mainscreen"></ImageView> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent"> 


    <Button android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:id="@+id/mainscreen_btchange" 
     android:text="Change State"></Button> 


    </RelativeLayout> 
    </LinearLayout> 

내 질문 : 어떻게 레이아웃의 모든 요소가 표시되는 사진을 축소하는 방법?

답변

1

많은 수의 항목을 표시해야하는 복잡한 레이아웃의 경우 일반적으로 가장 바깥 쪽 컨테이너로 RelativeLayout으로 시작합니다. layout_alignParentTop과 layout_alignParentBottom (네가 생각하는 세로 레이아웃의 경우)을 사용하여 말단에 있어야 할 것은 무엇이든 도킹하고, 다음으로 그들과 관련된 요소들의 다음 세트를 만드는 일을한다. 기본적으로 가장자리에서 시작하여 안으로 들어가십시오.

따라서 귀하의 경우 버튼의 속성은 android:layout_alignParentBottom="true"이고 TV의 값은 android:layout_above="@+id/mainscreen_btchange"이어야합니다. 상단에있는 텍스트 뷰가 android:layout_alignParentTop="true"이 없다해야하며 아래의 이미지 뷰가 android:layout_below="@+id/mainscreen"

+0

오류가 있어야합니다 속성 'layout_alignBelow'패키지 '안드로이드'에 대한 검색 자원 식별자를 – user547995

+0

죄송합니다 ... 그 layout_above 및 layout_below입니다. 코드 샘플도 수정했습니다. – Rich

+0

사진이 올바르게 표시되도록하고 싶습니다. 귀하의 코드는 사진으로 변경되지 않았습니다. – user547995

관련 문제