8
我想實現自定義的搜索條像下圖
自定義搜索條的Android
的,我沒有,我創建繪製的搜索條progressDrawable低於
的代碼讓我知道如果代碼是必需的,我會在這裏發佈。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/llScale"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:paddingBottom="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/sliderText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Bernard"
android:textColor="@color/blue"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@drawable/slider_background"
android:padding="3dp">
<SeekBar
android:id="@+id/ratingBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:max="10"
android:maxHeight="100dp"
android:thumbTintMode="multiply"
android:progressDrawable="@drawable/progressbar"
android:thumb="@drawable/ic_slider_secondary"/>
<TextView
android:id="@+id/seekBarHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:text="Drag slider across"
android:textColor="@color/dark_gray"/>
</FrameLayout>
<TextView
android:id="@+id/progressText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_slider_progress"
android:gravity="center"
android:textColor="@color/white"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>
但上面的代碼是什麼,我得到的是如下圖像
淺紅色沒有被完全填滿,它左派一些空間,並在末端圓走出boundries的。
搖籃
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
任何人都可以請幫我在我下面做2個改變了這種
你需要的是一個自定義進度'Drawable',您可以通過調用'搜索欄#setProgressDrawable(可繪製d)設置' – pskink
@pskink:我已經設置它在xml android:progressDrawable =「@ drawable/progressbar」 –