3
人們可以在XML創建一個搜索欄如下...安卓:設置maxHeight參數編程的進度/搜索欄
<SeekBar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bpseekbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="3dp"
android:max="100"
android:maxHeight="8dp"
...
現在我想,因爲我需要根據屏幕分辨率調整maxHeight(要做到這一點編程是的,我知道一個人不應該這樣做,但我有我的理由)。我沒有問題以編程方式設置參數,除了我無法找到如何設置maxHeight。我覺得我需要使用Attributes,但我找不到如何。任何提示?
所以如果我繼承seekbar。重寫onmeasure,並將max(mymax,onmeasureheight)作爲高度傳遞給超級應該可以工作? – 2012-03-21 11:53:21
改寫maxheight?取決於你的意思。 – 2012-03-21 11:55:01
它應該。檢查Android的ProgressBar.onMeasure源並查看如何使用mMaxHeight,然後同樣使用您的最大高度值。 – 2012-03-21 12:03:25