我想在佈局中製作一個帶有編碼寬度的seekbar,但是,一旦seekbar的harcoded寬度值超過某個值,seekbar的寬度將不會反映我設置的值。例如:Android的SeekBar長度不匹配layout_width值
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SeekBar
android:rotation="270"
android:id="@+id/volumeBar"
android:layout_width="50dp"
android:layout_margin="1px"
android:layout_height="wrap_content"
android:layout_centerInParent = "true"/>
</RelativeLayout>
產生一個短的seekbar,因爲它應該是因爲寬度決定它應該只有50dp長。這裏的佈局:
現在,當我將layout_width更改爲300dp時,我看到一個剪裁的seekbar,當然不是300dp長。下面有文件和佈局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SeekBar
android:rotation="270"
android:id="@+id/volumeBar"
android:layout_width="300dp"
android:layout_margin="1px"
android:layout_height="wrap_content"
android:layout_centerInParent = "true"/>
</RelativeLayout>
注:它看起來好像搜索條被限制爲相對佈局的寬度(紅色的矩形)和任何時間的搜索條的長度(由android:layout_width指定)將超過RelativeLayout的長度被限制的寬度。 如何讓我的seekbar服從我所需的硬編碼長度?
編輯:我已經在下面包含了父項活動的xml文件。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:baselineAligned="false"
android:keepScreenOn="true">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.25"
android:background="#ffdd4c4f"
android:orientation="vertical"
android:id="@+id/toolbarGestureOverlay" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="3.75">
<com.example.project.Multitouch
android:id="@+id/fretBoard"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#3EF20C"/>
</LinearLayout>
</LinearLayout>
我得到了同樣的問題。你有沒有得到解決方案! –
同一個!任何解決方案 – Minoru
我還沒有找到解決方案。 – Cody