我在使用LinearLayout時遇到了問題。線性佈局是垂直的。在佈局中有幾個項目,包括一個TextView,一個垂直的SeekBar和一個ImageView。Android:LinearLayout更新視圖時重新排列
每當我更新textView(即setText())我的佈局重新排列。 ImageView從底部到中間。同樣的事情發生,如果我替換ImageView中的drawable。
我想我指定我的佈局的方式有問題。這是有部分問題:
<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時並不完全理解線程模型。
感謝您的回覆。我已經變成了所有元素都看不見的東西。不幸的是,問題仍然存在。它似乎是子控制器觸發的'controlElementList12' LinearLinear佈局。 – EL45
在您的ImageView徽標中,嘗試將高度設置爲0dp,因爲您已將權重設置爲1 –
還嘗試避免使用負邊距 –