Дизайн макета: SurfaceView не отображается - PullRequest
0 голосов
/ 17 мая 2011

Я построил макет, который может отображать изображение в трех разных областях. Это не имело значения, когда я использовал изображение, но почему-то это не работает с видом на поверхность. В основном есть три области, подобные приведенным ниже, а третья область (или область № 3) - это место, где я хочу поместить изображение через вид с поверхности

<a href="http://imageshack.us/m/202/3189/000hjb.jpg" rel="nofollow noreferrer">http://imageshack.us/m/202/3189/000hjb.jpg</a>

Изображение, созданное SurfaceView, может отображаться в области № 1, но не на 2 и 3, как показано ниже.

<a href="http://img215.imageshack.us/img215/9891/111lcv.jpg" rel="nofollow noreferrer">http://img215.imageshack.us/img215/9891/111lcv.jpg</a>

Ниже приведен скриншот, который я пробовал с изображением, и у них не было проблем.

<a href="http://imageshack.us/m/199/7231/222mlr.jpg" rel="nofollow noreferrer">http://imageshack.us/m/199/7231/222mlr.jpg</a>

Понятия не имею. Я хочу поместить изображение, созданное SurfaceView, в области 2 и 3 с идентификатором 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>

Ответы [ 2 ]

1 голос
/ 18 мая 2011

Пока я работал над этим, я думаю, что это проблема использования SurfaceView с ScrollView.Поскольку SurfaceView - это представление, которое может рисовать даже весь экран (или поверх экрана), я думаю, что Android не хочет иметь его внутри ScrollView.

0 голосов
/ 18 мая 2011

Вы правы, SurfaceView не предназначен для размещения внутри ScrollView. Это подтверждает, а это дает вам больше советов о том, что вы можете сделать вместо этого.

...