【问题标题】:Layout design: SurfaceView doesn't display版面设计:SurfaceView 不显示
【发布时间】:2011-05-17 05:33:34
【问题描述】:

我已经构建了一个可以在三个不同区域显示图片的布局。当我使用图像视图时没关系,但不知何故它不适用于表面视图。基本上有下面三个区域,第三个区域(或3号区域)是我要通过surfaceview放图片的地方

@987654321@

SurfaceView制作的图片可以显示在1号区域,但不能显示在下面的2和3区域。

@987654322@

下面是我尝试使用 imageview 的屏幕截图,它们没有问题。

@987654323@

我不知道。我想要做的是将 SurfaceView 制作的图片放在区域 2 和 3 上,其 id 为 tableRow_cardImage - TableRow - 和 assistant_cardboard - LinearLayout。

如果有人有办法解决这个问题,请您帮帮我吗?

提前致谢,下面是我的xml布局代码


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<LinearLayout android:id="@+id/header" android:layout_height="wrap_content" android:layout_width="match_parent">
    <TextView android:id="@+id/header_life_title" android:textSize="20sp" android:text="Life: " android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
    <TextView android:id="@+id/header_life_value" android:textSize="20sp" android:text="20" android:layout_height="wrap_content" android:layout_width="wrap_content"></TextView>
    <Button android:text="Inc." android:id="@+id/header_btn_inc" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_gravity="center_vertical">
    <Button android:text="Dec." android:id="@+id/header_btn_dec" android:layout_width="wrap_content" android:layout_height="35dp">
    <Button android:text="Put L." android:id="@+id/header_btn_putLand" android:layout_width="wrap_content" android:layout_height="35dp">
    <Button android:text="Remove L." android:id="@+id/header_btn_removeLand" android:layout_width="wrap_content" android:layout_height="35sp">
    <LinearLayout android:layout_width="wrap_content" android:layout_height="match_parent" android:id="@+id/land_space">
    </LinearLayout>
</LinearLayout>
    <ScrollView android:id="@+id/scrollView1" android:layout_height="wrap_content" android:layout_width="match_parent">
        <LinearLayout android:id="@+id/linearLayoutInScrollview"
            android:orientation="horizontal" 
            android:layout_height="wrap_content"
            android:layout_width="wrap_content">
            <TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/cardboard">
                <LinearLayout android:layout_height="40dp"
                    android:layout_width="wrap_content" android:id="@+id/layout_menu">
                    <Spinner android:id="@+id/spinner_creature"
                        android:layout_height="wrap_content" 
                        android:layout_width="130dp">
                    <Button android:id="@+id/btn_creature"
                        android:layout_height="wrap_content" 
                        android:layout_width="wrap_content" android:text="Cast">
                    <Spinner android:id="@+id/spinner_noncreature"
                        android:layout_height="wrap_content" 
                        android:layout_width="130dp">
                    <Button android:id="@+id/btn_noncreature"
                        android:layout_height="wrap_content" 
                        android:layout_width="wrap_content" android:text="Cast">
                    <Button android:id="@+id/btn_delete"
                        android:layout_height="wrap_content" 
                        android:layout_width="wrap_content" android:text="Del."></Button>
                </LinearLayout>

                <TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardImage">
                <TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardData">
                <TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardImage2">
                <TableRow android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableRow_cardData2">
            </TableLayout>
            <LinearLayout android:layout_height="wrap_content" android:layout_width="wrap_content"
                android:id="@+id/assistant_cardboard"
                android:orientation="vertical" >
                <ImageView android:src="@drawable/icon" android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content"></ImageView>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>

【问题讨论】:

    标签: android android-linearlayout surfaceview


    【解决方案1】:

    当我在处理它时,我认为这是将 SurfaceView 与 ScrollView 一起使用的问题。由于 SurfaceView 是一个甚至可以绘制整个屏幕(或在屏幕上)的视图,我认为 android 不希望将它放在 ScrollView 内部。

    【讨论】:

    • 天哪,我已经找了好几个小时了,谢谢! (是的,甚至 2 年后 :))
    【解决方案2】:

    你是对的,SurfaceView 并不意味着放置在 ScrollView 中。 This 确认,this 为您提供更多关于您可以做什么的建议。

    【讨论】:

      猜你喜欢
      • 2012-10-26
      • 2011-08-04
      • 1970-01-01
      • 2011-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多