2010-12-06 3 views

답변

0

더 나은 사용 RelativeLayout의는 ....이 작업을 달성 적절한 변경을 확인하고 적절한 크기를 설정하는 가장 쉬운 방법이기 때문에 내가있는 LinearLayout 여기에 더 나은 생각

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
<ImageView 
     android:id="@+id/view1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
<TextView 
      android:layout_below="@id/view1" 
      android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 
<TextView 
     android:layout_toRightof="@id/view1" 
      android:layout_width="wrap_content" 
     android:layout_height="fill_parent"/> 


</RelativeLayout> 
0

를 사용하는 layout_weight를 사용합니다. LinearLayout에서 하나의 요소에만 0이 아닌 가중치를 설정하면 나머지 모든 공간이 사용됩니다. layout_weight는 나머지 공간을 주어진 가중치의 비율로 나눕니다. 주어진 layout_width-s (또는 height)를 먼저 설정 한 후에 남아있는 공간의 크기를 계산 한 다음이 크기를 덮어 씁니다. 몇 가지 초기 설정 후에 전체 화면을 고정 비율로 분할하고 남은 공간을 나누고 싶을 때는 먼저 요소의 크기를 0으로 설정해야합니다. View1의 크기를 wrap_content로 설정하고 적절한 방향을 0으로 설정하고 (다른 방향으로 부모를 채움) layout_weight = 1을 사용합니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
    android:orientation="vertical" android:layout_width ="wrap_content" 
    android:layout_height="fill_parent"> 
     <ImageView 
     android:id="@+id/view1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src=.../> 
    <SomeKindOfView 
     android:id="@+id/view2" 
     android:layout_width="fill_parent" 
     android:layout_height="0px" 
     android:layout_weight="1"/> 
    </LinearLayout> 
    <AnotherView 
    android:id="@+id/view3" 
    android:layout_width="0px" 
    android:layout_height="fill_parent" 
    android:layout_weight="1"/> 
</LinearLayout> 
관련 문제