2

作業中のアプリで LinearLayout に問題があります。線形レイアウトは垂直です。レイアウトには、TextView、垂直方向の SeekBar、ImageView などの項目がいくつかあります。

textView (つまり setText()) を更新するたびに、レイアウトが再配置されます。ImageView は最下部から中央に移動します。ImageView でドローアブルを置き換えると、同じことが起こります。

レイアウトの指定方法に問題があると思います。これは問題のある部分です:

        <modrobotics.code.ui.BlockValueSliderView
            android:id="@+id/sliderSix"
            android:layout_width="0dp"
            android:visibility="gone"
            android:layout_height="fill_parent"
            android:layout_marginBottom="-12dp"
            android:layout_weight="1"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/BVLabel"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="center_horizontal"
                android:paddingTop="12dp"
                android:text="64"
                android:textColor="#000"
                android:textSize="20sp" >
            </TextView>

            <View
                android:id="@+id/circle1"
                android:layout_width="6dp"
                android:layout_height="6dp"
                android:layout_gravity="center"
                android:layout_marginBottom="-6dp"
                android:background="@drawable/circle"
                android:gravity="center_horizontal"
                android:padding="0dp" />

            <LinearLayout
                android:id="@+id/controlElementList12"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical"
                android:padding="0dp" >

                <modrobotics.code.ui.VerticalSeekBar
                    android:id="@+id/slider"
                    android:layout_width="wrap_content"
                    android:layout_height="0dp"
                    android:layout_gravity="bottom|center_horizontal"
                    android:layout_marginBottom="-20dp"
                    android:layout_weight="20"
                    android:padding="0dp"
                    android:progressDrawable="@drawable/seekbar_progress"
                    android:thumb="@drawable/seekbar_thumb"
                    android:thumbOffset="-1dp" />

                <ImageView
                    android:id="@+id/logo"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center_horizontal"
                    android:layout_marginBottom="-20dp"
                    android:layout_marginTop="-20dp"
                    android:layout_weight="1"
                    android:padding="0dp"
                    android:src="@drawable/on6" >
                </ImageView>
            </LinearLayout>
        </modrobotics.code.ui.BlockValueSliderView>

編集:

以下の提案を試してみましたが、役に立ちませんでした。すべての負のマージンを削除し、不要な LinearLayout を削除してレイアウトを簡素化し、GONE を削除し、画像の高さを固定しました。問題はこれだけではないと考え始めています。

PageAdapter で単一のアクティビティを使用しています。PageAdapter を正しく使用していないようです。startUpdate() が何度も呼び出されています。私が持っている静的グローバル変数は、何らかの方法でクリーンアップされているか、別のスレッドにあるようです。これらの問題はすべて関連している可能性があると思います。おそらく、PageAdapter を使用するときのスレッド モデルを完全には理解していません。

4

2 に答える 2

0

これは、私が使用していた VerticalSeekBar の実装に関連する問題であることが判明しました。

シークバーの親指を回転させ、シークバーで BringToFront() を呼び出していました。これら 2 つの呼び出しの組み合わせにより、要素が再配置されました。理由はわかりませんが、これら 2 行のコードを削除することで問題が解決しました。

于 2012-11-15T17:26:26.410 に答える
0

「modrobotics.code.ui.BlockValueSliderView」で、可視性を GONE から INVISIBLE に変更します。このビューの可視性をプログラムで GONE から VISIBLE に変更するたびに、レイアウト要素が再配置される可能性があります。これは、ビューが GONE に設定されている間、レイアウト内のスペースを占有せず、残りのビューが配置されるためです。スペースを取るだけのレイアウトで。GONE の場合、レイアウトに存在しないかのように動作します。次に、このビューを VISIBLE に設定すると、レイアウト内の残りのビューが切り替わり、そのレフのスペースが準備されます。

于 2012-10-18T00:00:26.813 に答える