【问题标题】:Problems with layout_height used inside RelativeLayout in android 1.5android 1.5 中的 RelativeLayout 中使用的 layout_height 问题
【发布时间】:2010-08-01 00:43:25
【问题描述】:

这是我在 android 中的图像捕获程序的布局

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

        <SurfaceView android:id="@+id/surface_camera"
            android:layout_width="fill_parent" android:layout_height="420px">
        </SurfaceView>

    <RelativeLayout android:layout_width="fill_parent"
        android:layout_alignParentBottom="true" android:id="@+id/beforeClick"
        android:layout_height="wrap_content" android:background="@color/clickPanelBK"
        android:paddingTop="6dp" android:paddingBottom="6dp">
        <Button android:gravity="center" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/capture_image_goback_btn"
            android:background="@drawable/generalbutton" android:text="@string/back" />
        <Button android:gravity="center"
            android:layout_centerHorizontal="true" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/capture_image_btn"
            android:background="@drawable/clickbutton" />
    </RelativeLayout>

    <RelativeLayout android:layout_width="fill_parent"
        android:layout_alignParentBottom="true" android:id="@+id/afterClick"
        android:layout_height="wrap_content" android:background="@color/clickPanelBK"
        android:paddingTop="6dp" android:paddingBottom="6dp">
        <Button android:gravity="center" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/img_retake"
            android:background="@drawable/generalbutton" android:text="@string/retake" />
        <Button android:gravity="center"
            android:layout_alignParentRight="true" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:id="@+id/img_save"
            android:text="@string/saveImg" android:background="@drawable/generalbutton" />
    </RelativeLayout>

</RelativeLayout>

最后 2 个相对布局是可交换的并且可以很好地对齐。一次只出现一个,并在单击按钮时更改。无论如何,这里的问题是,我不得不提到以px或dp为单位的surface view的layout_height。如果我将 layout_height 设置为 fill_parent,则视图看起来非常小,只有 35% 的宽度和高度。谁能给我一个解决方案?

【问题讨论】:

标签: android android-emulator


【解决方案1】:

RelativeLayout 在 1.5 中有很多 bug :(

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-22
    • 2011-09-28
    相关资源
    最近更新 更多