2012-04-28 4 views
3

사용자가 버튼을 누를 때 나타나는 작업 시트를 디자인했습니다. 그것은 다른 레이아웃 파일에 포함하고있는 별도의 XML 파일입니다. 레이아웃 미리보기에서 원하는대로 정확하게 나타납니다. 그러나 휴대 전화에서 실행되면 레이아웃이 엉망입니다.레이아웃이 미리보기와 일치하지 않습니다.

Should Look

그리고 여기 좀 어때입니다 : 여기

는 보는 방법이다 Does Look

사람이 이런 일이 될 수있는 이유는 어떤 생각을 가지고 있습니까?

다음은 작업 시트의 레이아웃 코드입니다. 바로 표시되지 않는 섹션은 마지막 선형 레이아웃

<?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="wrap_content" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/sheet_header" > 

     <ImageButton 
      android:id="@+id/left_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:layout_toLeftOf="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_left" /> 

     <ImageButton 
      android:id="@+id/center_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="13dp" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_center" /> 

     <ImageButton 
      android:id="@+id/right_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:layout_toRightOf="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_right" /> 

     <ImageButton 
      android:id="@+id/close_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@+id/center_justified" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/sheet_done_btn" 
      /> 
    </RelativeLayout> 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/sheet_background" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="15dp" > 

      <TextView 
       android:id="@+id/font_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1.0" 
       android:gravity="center" 
       android:text="Font" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/size_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1.0" 
       android:gravity="center" 
       android:text="Size" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/color_text" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1.0" 
       android:gravity="center" 
       android:text="Color" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 
     </LinearLayout> 
    </LinearLayout> 

</LinearLayout> 

을에 그리고 여기 포함되는 방법은 다음과 같습니다

<FrameLayout 
    android:layout_alignParentBottom="true" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/edit_text_frame"> 

    <include layout="@layout/edit_text"/> 
</FrameLayout> 

편집 : 아는 사람 않습니다이 특정 문제에 대한 수정에 추가 미리보기가 실제로 전화 상에 나타나는 방식과 일치하지 않는 이유는 무엇입니까?

도움 주셔서 감사합니다.

+0

왜 하단에 LinearLayouts가 중첩되어 있습니까? – Sam

+0

미완성 된 레이아웃입니다. 그 선형 레이아웃 내에 몇 가지 요소를 추가해야합니다. – amc6

답변

0
<?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="wrap_content" 
    android:orientation="vertical" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/sheet_header" > 

     <ImageButton 
      android:id="@+id/left_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:layout_toLeftOf="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_left" /> 

     <ImageButton 
      android:id="@+id/center_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="13dp" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_center" /> 

     <ImageButton 
      android:id="@+id/right_justified" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:layout_toRightOf="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:src="@drawable/alignment_right" /> 

     <ImageButton 
      android:id="@+id/close_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/center_justified" 
      android:background="@android:color/transparent" 
      android:layout_alignParentRight="true" 
      android:layout_alignTop="@+id/center_justified" 
      android:layout_marginRight="10dp" 
      android:src="@drawable/sheet_done_btn" 
      /> 
    </RelativeLayout> 



     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="15dp" 
     android:background="@drawable/sheet_background" 
     android:orientation="vertical" > 

      <TextView 
       android:id="@+id/font_text" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="center" 
       android:text="Font" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/size_text" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="center" 
       android:text="Size" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 

      <TextView 
       android:id="@+id/color_text" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:gravity="center" 
       android:text="Color" 
       android:textColor="#806014" 
       android:textSize="20sp" /> 
     </LinearLayout> 


</LinearLayout> 
0

글꼴, 크기, 색상 TextViews를 표 레이아웃에 배치 할 수 있습니다.

관련 문제