導航:首頁 > 操作系統 > android垂直seekbar

android垂直seekbar

發布時間:2023-01-10 02:29:25

android:如何將進度條(SeekBar),豎著布局

讀seekbar的源碼,將方想反過來即可,在巴士上有現成的,你可以看看這個 http://www.apkbus.com/forum.php?mod=viewthread&tid=82748

㈡ Android開發如何更改SeekBar式樣

改變seekbar上的按鈕通過設置android:thumb屬性

改變seekbar的那個條設置android:progressDrawable屬性

示例

按鈕圖片

<shape>
<solidandroid:color="@android:color/black"/>
<sizeandroid:width="2dp"android:height="10dp"/>
</shape>

進度條圖片

<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<layer-list>
<itemandroid:id="@android:id/background">
<shape>
<gradient
android:startColor="#1DDA0B"
android:centerColor="#F5DA0B"
android:endColor="#D10000"
android:centerX="0.2"/>
</shape>
</item>
</layer-list>
</item>
</selector>


給seekbar設置屬性

<SeekBar
android:id="@+id/seek_aqi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_aqi_text"
android:padding="0dp"
android:thumb="@drawable/seek_aqi_thumb"
android:progressDrawable="@drawable/seek_aqi_bg"
android:max="500"
android:maxHeight="5dp"
android:minHeight="5dp"
android:progress="70"/>

效果

㈢ android 帶節點的seekbar怎麼搞

sdk裡面沒有提供設置成垂直的方法 要自己去實現 查看原帖>>

㈣ 求助,Android裡面的seekbar怎麼垂直顯示

把seekbar復寫了。。旋轉90度就可以了。

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.SeekBar;

public class SlideBar extends SeekBar {

private int oHeight = 100;
private int oWidth = 30;
private int oProgress = -1;
private int oOffset = -1;;
private float xPos = -1;
private float yPos = -1;
private int top = -1;
private int bottom = -1;
private int left = -1;
private int right = -1;

public SlideBar(Context context) {

super(context);
}

public SlideBar(Context context, AttributeSet attrs) {

super(context, attrs);
oOffset = this.getThumbOffset();
oProgress = this.getProgress();
}

public SlideBar(Context context, AttributeSet attrs, int defStyle) {

super(context, attrs, defStyle);
}

protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

int height = View.MeasureSpec.getSize(heightMeasureSpec);
oHeight = height;
this.setMeasuredDimension(oWidth, oHeight);
}

protected void onSizeChanged(int w, int h, int oldw, int oldh) {

super.onSizeChanged(h, w, oldw, oldh);
}

// 設置layout
protected void onLayout(boolean changed, int l, int t, int r, int b) {

super.onLayout(changed, l, t, r, b);
left = l;
right = r;
top = t;
bottom = b;
}

// 畫出滾動條
protected void onDraw(Canvas c) {
// 旋轉
c.rotate(90);
//控制左右位置
c.translate(0,-30);
super.onDraw(c);
}

public boolean onTouchEvent(MotionEvent event) {

xPos = event.getX();
yPos = event.getY();
float progress = 1-(yPos-this.getTop())/(this.getBottom()- this.getTop());
oOffset = this.getThumbOffset();
oProgress = this.getProgress();
Log.d("offset" + System.nanoTime(), new Integer(oOffset).toString());
Log.d("progress" + System.nanoTime(), new Integer(oProgress).toString());
float offset;
offset = progress * (this.getBottom() - this.getTop());
this.setThumbOffset((int)offset);
Log.d("offset_postsetprogress" + System.nanoTime(), new Integer(oOffset).toString());
Log.d("progress_postsetprogress" + System.nanoTime(), new Integer(oProgress).toString());
// this.setProgress((int)(100*event.getY()/this.getBottom()));
this.setProgress((int)(100 * progress));
return true;
}
}

閱讀全文

與android垂直seekbar相關的資料

熱點內容
用什麼app可以找校友 瀏覽:100
雲伺服器刪除實例再創建要付錢嗎 瀏覽:347
wifi的加密類型從哪裡看 瀏覽:627
為什麼手機有的app顯示沒網 瀏覽:44
黑馬程序員入學知識 瀏覽:795
計算機編譯器使用 瀏覽:35
為什麼花雨庭伺服器會閃退 瀏覽:5
cad的xc命令 瀏覽:898
程序員初級和大佬的區別 瀏覽:546
安卓機怎麼進入調試狀態 瀏覽:176
壓縮機運行與維修實用技術 瀏覽:727
編譯原理程序語言 瀏覽:319
安慶緩解壓力頭部按摩儀用途 瀏覽:576
帶括弧的除法演算法 瀏覽:488
pdf登陸 瀏覽:831
微雲的文件夾怎麼下載到手機 瀏覽:291
大廠高薪招聘程序員 瀏覽:12
看長篇小說用什麼app 瀏覽:955
部路沖突安卓怎麼轉到ios 瀏覽:631
騰訊微雲解壓用vip嗎 瀏覽:259