我设计了一个操作表,当用户按下按钮时会出现。它是一个单独的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="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>
编辑:除了针对这个特定问题的解决办法之外,有人知道为什么预览不符合它在手机上实际显示的方式吗?
感谢帮助!