2012-05-24 3 views
-1

내가 가지고있는 주요있는 LinearLayout에서 다음 XML 코드안드로이드 레이아웃 고정 된 크기

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight=".10"> 
     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#aa0000" 
      android:text="top"/>  

    </LinearLayout> 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight=".70"> 

     <ScrollView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:background="#00aa00"> 
      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:orientation="vertical"> 
       <TextView 

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"    
        android:textSize="50pt" 
        android:text="center"> 
       </TextView> 
       <TextView 

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"    
        android:textSize="50pt" 
        android:text="center"> 
       </TextView> 
       <TextView 

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"    
        android:textSize="50pt" 
        android:text="center"> 
       </TextView> 
       <TextView 

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"    
        android:textSize="50pt" 
        android:text="center"> 
       </TextView> 
       <TextView 

        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"    
        android:textSize="50pt" 
        android:text="center"> 
       </TextView> 
      </LinearLayout> 
     </ScrollView> 
    </LinearLayout>  
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:background="@android:color/white" 
     android:layout_weight=".20"> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#0000aa" 
      android:text="bottom"/> 
     </LinearLayout>   


</LinearLayout> 

내가 세의 LinearLayout 있습니다. 첫 번째 LinearLayout 들어, 100px 설정해야합니다. 세 번째 LinearLayout 들어, 내가 200px를 설정해야합니다. 그리고 두 번째 LinearLayout의 다른 모든 크기.

+0

질문이없는 것 같습니다. 단순히 원하는 크기를 설정하는 방법은? (사용할 태그를 모르는 경우 문서를 확인하십시오) – keyser

답변

1

Android에서 고정 크기를 사용하면 다른 화면 해상도로 레이아웃이 깨질 수 있으므로 사용하지 않는 것이 좋습니다. 이 유형의 화면 비율을 정의하려면 android:layout_weight을 사용해야합니다. 마지막으로 레이아웃 크기를 정의하는 데 px를 사용하지 말고 dp 및 sp를 사용하여 텍스트 크기를 pt로 지정하십시오.