问题描述
我尝试了一些东西,但我无法解决它们。
有人知道为什么会这样吗?
XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<TextView
android:id="@+id/tv_quota"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF233845"
android:textSize="15sp" />
<SeekBar
android:id="@+id/sb_quota"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:thumb="@drawable/seeker" />
自定义类
public class CustomSeeker extends LinearLayout {
private SeekBar sb_quota;
private TextView tv_quota;
private Context mContext;
public CustomSeeker(Context context) {
super(context);
this.mContext = context;
init();
}
public CustomSeeker(Context context,AttributeSet attrs) {
super(context,attrs);
this.mContext = context;
init();
}
private void init() {
inflate(mContext,R.layout.mdnslider,this);
tv_quota = findViewById(R.id.tv_quota);
sb_quota = findViewById(R.id.sb_quota);
sb_quota.setonSeekBarchangelistener(new SeekBar.OnSeekBarchangelistener() {
@Override
public void onProgressChanged(SeekBar seekBar,int progress,boolean fromUser) {
int val = (progress * (seekBar.getWidth() - 2 * seekBar.getThumbOffset())) / seekBar.getMax();
tv_quota.setText("" + progress);
tv_quota.setX(seekBar.getX() + val + seekBar.getThumbOffset() / 2);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
}
}
如果有人知道如何解决它或有想法,我将不胜感激,我已经尝试解决这个问题几天了。
我也尝试对 textview
和 seekbar
应用边距,但效果不佳。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)