的onDraw()不会被调用 [英] onDraw() not being called
问题描述
我的工作固定某人的Android应用程序。它最初是为2.1做,我试图让它工作4.0+。不幸的是谁提出的应用软件的人不在身边,所以我坚持自己的code。
该应用程序实现了定制的滑块,水平和垂直。我得到了垂直滑块固定的,但我不能让水平滑块工作。他并没有叫的onDraw()
:当视图加载,的onDraw()
被调用,我看到我的两个滑块初始化,然后当我将我的水平滑块它移动和呼叫的onDraw()
一次,但绝不会再就调用它,不像垂直滑块,不会调用它。
下面是code:
公共类PanSeekBar扩展RelativeLayout的{ 私人的RelativeLayout布局1;
公共ImageView的轨道;
公共ImageView的大拇指; 公共布尔初始化= FALSE;
公众诠释thumbDownPosX = 0;
公众诠释thumbDownPosY = 0;
公众诠释thumbLeft = 0;
公众诠释thumbTop = 0;
公众诠释thumbRight = 0;
公众诠释thumbBottom = 0;
私人INT最大= 100; 公共布尔感动= FALSE; 公共PanSeekBar(上下文的背景下){
超级(上下文);
初始化(上下文);
// TODO自动生成构造函数存根
} // PanSeekBar构造结束 私人无效初始化(上下文的背景下){
Log.d(初始化(PanSeekBar),初始化);
setWillNotDraw(假); LayoutInflater吹气=(LayoutInflater)上下文
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
查看视图1 = inflater.inflate(R.layout.pan_seekbar,这一点); 布局1 =(RelativeLayout的)view1.findViewById(R.id.ps_layout1);
轨=(ImageView的)layout1.findViewById(R.id.ps_track);
拇指=(ImageView的)layout1.findViewById(R.id.ps_thumb); thumb.setOnTouchListener(新OnTouchListener(){ @覆盖
公共布尔onTouch(视图V,MotionEvent事件){
初始化= TRUE; 开关(event.getAction()){
案例MotionEvent.ACTION_DOWN:
Log.d(onTouch(PanSeekBar),操作下);
thumbDownPosX =(int)的event.getX();
thumbDownPosY =(int)的event.getY(); thumbLeft = thumb.getLeft();
thumbTop = thumb.getTop();
thumbRight = thumb.getRight();
thumbBottom = thumb.getBottom();
感动= TRUE;
打破; 案例MotionEvent.ACTION_MOVE:
// Log.d(onTouch(PanSeekBar),动作移动);
INT左=(int)的(thumb.getLeft()+ event.getX() - thumbDownPosX);
如果(左℃,){
左边= 0;
Log.d(onTouch(PanSeekBar),左℃的:+左);
}否则如果(左&GT = track.getWidth() - thumb.getWidth()){
左= track.getWidth() - thumb.getWidth();
Log.d(onTouch(PanSeekBar),
左> = track.getWidth():+左);
}
INT顶= thumb.getTop();
INT右=左+ thumb.getWidth();
INT底部=顶部+ thumb.getHeight(); thumbLeft =左;
thumbTop =顶部;
thumbRight =权利;
thumbBottom =底部; Log.d(onTouch(PanSeekBar),
动作移动 - 拇指布局:+ thumbLeft +,
+ thumbTop +,+ thumbRight +,
+ thumbBottom); layout1.invalidate();
// thumb.invalidate(); 打破; 案例MotionEvent.ACTION_UP:
Log.d(onTouch(PanSeekBar),操作上);
感动= FALSE;
打破;
} //开关结束 返回true;
} // onTouch结束
});
} //初始化结束 @覆盖
保护无效的onDraw(帆布油画){
Log.d(的onDraw(PanSeekBar),的onDraw);
super.onDraw(画布); 如果(初始化){
thumb.layout(thumbLeft,thumbTop,thumbRight,thumbBottom);
Log.d(的onDraw(PanSeekBar),拇指布局:+ thumbLeft +,
+ thumbTop +,+ thumbRight +,+ thumbBottom);
}
} //的onDraw结束
} // PanSeekBar结束
下面是code的垂直滑块,做的工作:
公共类MySeekBar扩展RelativeLayout的{ 私人的RelativeLayout布局1;
公共ImageView的轨道;
公共ImageView的大拇指;
私人MyToast敬酒;
私人MyToast烤面包;
私人MyToast toast3;
私人诠释globalMaxValue;
私人诠释globalProgress; 初始化= FALSE私人布尔;
公众诠释thumbDownPosX = 0;
公众诠释thumbDownPosY = 0;
公众诠释thumbLeft = 0;
公众诠释thumbTop = 0;
公众诠释thumbRight = 0;
公众诠释thumbBottom = 0; 私人INT globalSetProgress = 0;
私人INT globalConfigType = 1; //保证金顶部custom_seekbar.xml
私人INT marginTop = 20;
公共布尔感动= FALSE; 公共MySeekBar(上下文的背景下){
超级(上下文);
// TODO自动生成构造函数存根
初始化(上下文);
} // MySeekBar结束 公共无效初始化(上下文的背景下){
Log.d(初始化(MySeekBar),初始化);
setWillNotDraw(假); LayoutInflater吹气=(LayoutInflater)上下文
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
查看视图1 = inflater.inflate(R.layout.custom_seekbar,这一点); 布局1 =(RelativeLayout的)view1.findViewById(R.id.al_cs_layout1);
轨=(ImageView的)layout1.findViewById(R.id.cs_track);
拇指=(ImageView的)layout1.findViewById(R.id.cs_thumb); //获取marginTop
MarginLayoutParams PARAMS =(MarginLayoutParams)轨道
.getLayoutParams();
Log.d(初始化(MySeekBar),当前margintop =+ marginTop);
marginTop = params.topMargin;
Log.d(初始化(MySeekBar),新margintop =+ marginTop); // INT marginTopPixelSize = params.topMargin;
// Log.d(初始化(MySeekBar),调试=+ marginTopPixelSize); //贾里德
//当创建MyToast,设置宽度导致的问题。
敬酒=新MyToast(背景);
toast.setText();
toast.setBackgroundColor(Color.LTGRAY);
toast.setTextColor(Color.BLACK);
toast.setPadding(1,1,1,1);
toast.setVisibility(View.INVISIBLE);
toast.setTextSize(10F);
// toast.setWidth(40); 烤面包=新MyToast(背景);
toast2.setTextSize(12F);
toast2.setTextColor(Color.rgb(192,255,3));
// toast2.setWidth(40);
toast2.setPadding(10,1,1,1);
// toast2.setBackgroundColor(Color.BLACK);
toast2.setVisibility(View.INVISIBLE); toast3 =新MyToast(背景);
toast3.setText(CH);
toast3.setTextSize(15F);
toast3.setTextColor(Color.rgb(192,255,3));
// toast3.setWidth(40);
toast3.setPadding(1,1,1,1); layout1.addView(面包);
layout1.addView(烤面包);
layout1.addView(toast3); thumb.setOnTouchListener(新OnTouchListener(){ @覆盖
公共布尔onTouch(视图V,MotionEvent事件){
初始化= TRUE; // 0 =跌1 =上涨2 =移动
// Log.d(onTouch(MySeekBar),
// Integer.toString(event.getAction()));
开关(event.getAction()){
案例MotionEvent.ACTION_DOWN:
Log.d(onTouch(MySeekBar),操作下);
thumbDownPosX =(int)的event.getX();
thumbDownPosY =(int)的event.getY();
//拇指位置感动。不相干的规模
// Log.d(onTouch(NewSeekBar),thumbDownPosX+ thumbDownPosX +thumbDownPosY+ thumbDownPosY);
thumbLeft = thumb.getLeft();
thumbTop = thumb.getTop();
thumbRight = thumb.getRight();
thumbBottom = thumb.getBottom();
感动= TRUE;
toast2.setVisibility(View.INVISIBLE);
toast3.setVisibility(View.INVISIBLE);
toast.setVisibility(View.VISIBLE);
拇指按钮//位置/尺寸
// Log.d(onTouch(NewSeekBar),thumbLeft+ thumbLeft +thumbRight+ thumbRight +thumbTop+ thumbTop +thumbBottom+ thumbBottom); 打破; 案例MotionEvent.ACTION_MOVE:
// Log.d(onTouch(MySeekBar),动作移动);
INT thumbHeight = thumb.getHeight();
INT thumbWidth = thumb.getWidth();
INT trackWidth = track.getWidth();
INT trackHeight = track.getHeight();
拇指按钮,轨道//位置/尺寸
// Log.d(onTouch(NewSeekBar),thumbHeight+ thumbHeight +thumbWidth+ thumbWidth +trackWidth+ trackWidth +trackHeight+ trackHeight); INT顶=(int)的(thumb.getTop()+ event.getY() - thumbDownPosY);
Log.d(onTouch(NewSeekBar),顶+顶部); //顶部边框
如果(顶部< marginTop){
顶部= marginTop;
Log.d(onTouch(NewSeekBar),顶< marginTop+顶部);
}否则如果(顶部> = trackHeight - thumbHeight + marginTop){
顶部= trackHeight - thumbHeight + marginTop;
Log.d(onTouch(NewSeekBar),顶> = trackHeight
+顶部);
} thumbLeft = thumb.getLeft();
;
thumbTop =顶部;
thumbRight = thumbLeft + thumbWidth;
thumbBottom =顶部+ thumbHeight; // Log.d(onTouch(MySeekBar),
//thumbTop:+ thumbTop +thumbBottom:+ thumbBottom);
int值= getProgress();
Log.d(onTouch(NewSeekBar),getProgress():+值);
// setdBText(值); // Log.d(onTouch(MySeekBar),值:+值);
setProgress(值);
// toast.setText(将String.valueOf(临时));
// toast2.setText(将String.valueOf(临时));
layout1.invalidate(); 打破; 案例MotionEvent.ACTION_UP:
Log.d(onTouch(MySeekBar),操作上);
toast.setVisibility(View.INVISIBLE);
toast2.setVisibility(View.VISIBLE);
toast3.setVisibility(View.VISIBLE);
感动= FALSE;
打破;
} //开关结束
返回true;
} // onTouch结束
});
} //初始化结束 @覆盖
保护无效的onDraw(帆布油画){
Log.d(的onDraw(MySeekBar),的onDraw);
super.onDraw(画布); 如果(初始化){
thumb.layout(thumbLeft,thumbTop,thumbRight,thumbBottom);
Log.d(的onDraw(MySeekBar),拇指布局:+ thumbLeft +,
+ thumbTop +,+ thumbRight +,+ thumbBottom);
INT顶部= thumbTop - marginTop;
INT左= thumbLeft + 4;
// toast.layout(左,上,左+ toast.getWidth(),顶+
// toast.getHeight()); 顶= thumbTop + thumb.getHeight()/ 2 - toast2.getHeight()/ 2 + 1;
左= thumbLeft;
toast2.layout(左,上,左+ toast2.getWidth()
顶+ toast2.getHeight());
}
} //的onDraw结束
中的XML:
<?XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直
机器人:ID =@ + ID / test_layout> <的LinearLayout
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向> < com.networksound.Mixer3.NewSeekBar
机器人:ID =@ + ID / newSeekBar1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.NewSeekBar> < com.networksound.Mixer3.NewSeekBar
机器人:ID =@ + ID / newSeekBar2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.NewSeekBar> < com.networksound.Mixer3.MySeekBar
机器人:ID =@ + ID / mySeekBar1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.MySeekBar> < com.networksound.Mixer3.MySeekBar
机器人:ID =@ + ID / mySeekBar2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.MySeekBar> < / LinearLayout中> <的LinearLayout
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直> < com.networksound.Mixer3.PanSeekBar
机器人:ID =@ + ID / panSeekBar1
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.PanSeekBar> < com.networksound.Mixer3.PanSeekBar
机器人:ID =@ + ID / panSeekBar2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< /com.networksound.Mixer3.PanSeekBar> < / LinearLayout中>
< / LinearLayout中>
如果你伸出的的ViewGroup
就应该把控 dispatchDraw()
而不是的onDraw()
,或在构造函数中,调用 setWillNotDraw(假)
。有一个关于它这里一些讨论。
I am working on fixing someone's Android app. It was originally made for 2.1 and I am trying to get it work to 4.0+. Unfortunately the person who made the app is not around so I am stuck with his code.
The app implements custom sliders, a horizontal and vertical. I got the vertical slider fixed, but I cannot get the horizontal slider to work. It is not calling onDraw()
: When the view loads, onDraw()
gets called and I see both of my sliders initialized, then when I move my horizontal slider it moves and calls onDraw()
once, but never again will it call it, unlike the vertical slider which does call it.
Here is the code:
public class PanSeekBar extends RelativeLayout {
private RelativeLayout layout1;
public ImageView track;
public ImageView thumb;
public boolean initialized = false;
public int thumbDownPosX = 0;
public int thumbDownPosY = 0;
public int thumbLeft = 0;
public int thumbTop = 0;
public int thumbRight = 0;
public int thumbBottom = 0;
private int max = 100;
public boolean touched = false;
public PanSeekBar(Context context) {
super(context);
initialize(context);
// TODO Auto-generated constructor stub
}// End of PanSeekBar Constructor
private void initialize(Context context) {
Log.d("initialize (PanSeekBar)", "initialize");
setWillNotDraw(false);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view1 = inflater.inflate(R.layout.pan_seekbar, this);
layout1 = (RelativeLayout) view1.findViewById(R.id.ps_layout1);
track = (ImageView) layout1.findViewById(R.id.ps_track);
thumb = (ImageView) layout1.findViewById(R.id.ps_thumb);
thumb.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
initialized = true;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("onTouch (PanSeekBar)", "Action Down");
thumbDownPosX = (int) event.getX();
thumbDownPosY = (int) event.getY();
thumbLeft = thumb.getLeft();
thumbTop = thumb.getTop();
thumbRight = thumb.getRight();
thumbBottom = thumb.getBottom();
touched = true;
break;
case MotionEvent.ACTION_MOVE:
// Log.d("onTouch (PanSeekBar)", "Action Move");
int left = (int) (thumb.getLeft() + event.getX() - thumbDownPosX);
if (left < 0) {
left = 0;
Log.d("onTouch (PanSeekBar)", "left < 0: " + left);
} else if (left >= track.getWidth() - thumb.getWidth()) {
left = track.getWidth() - thumb.getWidth();
Log.d("onTouch (PanSeekBar)",
"left >= track.getWidth(): " + left);
}
int top = thumb.getTop();
int right = left + thumb.getWidth();
int bottom = top + thumb.getHeight();
thumbLeft = left;
thumbTop = top;
thumbRight = right;
thumbBottom = bottom;
Log.d("onTouch (PanSeekBar)",
"Action Move -- thumb layout: " + thumbLeft + ", "
+ thumbTop + ", " + thumbRight + ", "
+ thumbBottom);
layout1.invalidate();
// thumb.invalidate();
break;
case MotionEvent.ACTION_UP:
Log.d("onTouch (PanSeekBar)", "Action Up");
touched = false;
break;
}// End of switch
return true;
}// End of onTouch
});
}// End of initialize
@Override
protected void onDraw(Canvas canvas) {
Log.d("onDraw (PanSeekBar)", "onDraw");
super.onDraw(canvas);
if (initialized) {
thumb.layout(thumbLeft, thumbTop, thumbRight, thumbBottom);
Log.d("onDraw (PanSeekBar)", "thumb layout: " + thumbLeft + ", "
+ thumbTop + ", " + thumbRight + ", " + thumbBottom);
}
}// End of onDraw
}// End of PanSeekBar
Here is the code for the vertical slider that does work:
public class MySeekBar extends RelativeLayout {
private RelativeLayout layout1;
public ImageView track;
public ImageView thumb;
private MyToast toast;
private MyToast toast2;
private MyToast toast3;
private int globalMaxValue;
private int globalProgress;
private boolean initialized = false;
public int thumbDownPosX = 0;
public int thumbDownPosY = 0;
public int thumbLeft = 0;
public int thumbTop = 0;
public int thumbRight = 0;
public int thumbBottom = 0;
private int globalSetProgress = 0;
private int globalConfigType = 1;
// Margin top in custom_seekbar.xml
private int marginTop = 20;
public boolean touched = false;
public MySeekBar(Context context) {
super(context);
// TODO Auto-generated constructor stub
initialize(context);
}// End of MySeekBar
public void initialize(Context context) {
Log.d("initialize (MySeekBar)", "initialize");
setWillNotDraw(false);
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view1 = inflater.inflate(R.layout.custom_seekbar, this);
layout1 = (RelativeLayout) view1.findViewById(R.id.al_cs_layout1);
track = (ImageView) layout1.findViewById(R.id.cs_track);
thumb = (ImageView) layout1.findViewById(R.id.cs_thumb);
// Gets marginTop
MarginLayoutParams params = (MarginLayoutParams) track
.getLayoutParams();
Log.d("initialize (MySeekBar)", "current margintop = " + marginTop);
marginTop = params.topMargin;
Log.d("initialize (MySeekBar)", "new margintop = " + marginTop);
// int marginTopPixelSize = params.topMargin;
// Log.d("initialize (MySeekBar)","debug = "+marginTopPixelSize);
// Jared
// When creating MyToast, setting width causes issues.
toast = new MyToast(context);
toast.setText("");
toast.setBackgroundColor(Color.LTGRAY);
toast.setTextColor(Color.BLACK);
toast.setPadding(1, 1, 1, 1);
toast.setVisibility(View.INVISIBLE);
toast.setTextSize(10f);
// toast.setWidth(40);
toast2 = new MyToast(context);
toast2.setTextSize(12f);
toast2.setTextColor(Color.rgb(192, 255, 3));
// toast2.setWidth(40);
toast2.setPadding(10, 1, 1, 1);
// toast2.setBackgroundColor(Color.BLACK);
toast2.setVisibility(View.INVISIBLE);
toast3 = new MyToast(context);
toast3.setText("CH");
toast3.setTextSize(15f);
toast3.setTextColor(Color.rgb(192, 255, 3));
// toast3.setWidth(40);
toast3.setPadding(1, 1, 1, 1);
layout1.addView(toast);
layout1.addView(toast2);
layout1.addView(toast3);
thumb.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
initialized = true;
// 0=down 1=up 2=move
// Log.d("onTouch (MySeekBar)",
// Integer.toString(event.getAction()));
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
Log.d("onTouch (MySeekBar)", "Action Down");
thumbDownPosX = (int) event.getX();
thumbDownPosY = (int) event.getY();
// Position of thumb touched. Irrelevant to scale
// Log.d("onTouch (NewSeekBar)","thumbDownPosX "+thumbDownPosX+" thumbDownPosY "+thumbDownPosY);
thumbLeft = thumb.getLeft();
thumbTop = thumb.getTop();
thumbRight = thumb.getRight();
thumbBottom = thumb.getBottom();
touched = true;
toast2.setVisibility(View.INVISIBLE);
toast3.setVisibility(View.INVISIBLE);
toast.setVisibility(View.VISIBLE);
// Location/size of the thumb button
// Log.d("onTouch (NewSeekBar)","thumbLeft "+thumbLeft+" thumbRight "+thumbRight+" thumbTop "+thumbTop+" thumbBottom "+thumbBottom);
break;
case MotionEvent.ACTION_MOVE:
// Log.d("onTouch (MySeekBar)", "Action Move");
int thumbHeight = thumb.getHeight();
int thumbWidth = thumb.getWidth();
int trackWidth = track.getWidth();
int trackHeight = track.getHeight();
// Location/size of the thumb button and track
// Log.d("onTouch (NewSeekBar)","thumbHeight "+thumbHeight+" thumbWidth "+thumbWidth+" trackWidth "+trackWidth+" trackHeight "+trackHeight);
int top = (int) (thumb.getTop() + event.getY() - thumbDownPosY);
Log.d("onTouch (NewSeekBar)", "top " + top);
// Top border
if (top < marginTop) {
top = marginTop;
Log.d("onTouch (NewSeekBar)", "top < marginTop " + top);
} else if (top >= trackHeight - thumbHeight + marginTop) {
top = trackHeight - thumbHeight + marginTop;
Log.d("onTouch (NewSeekBar)", "top >= trackHeight "
+ top);
}
thumbLeft = thumb.getLeft();
;
thumbTop = top;
thumbRight = thumbLeft + thumbWidth;
thumbBottom = top + thumbHeight;
// Log.d("onTouch (MySeekBar)",
// "thumbTop: "+thumbTop+" thumbBottom: "+thumbBottom);
int value = getProgress();
Log.d("onTouch (NewSeekBar)", "getProgress(): " + value);
// setdBText(value);
// Log.d("onTouch (MySeekBar)", "value: "+value);
setProgress(value);
// toast.setText(String.valueOf(temp));
// toast2.setText(String.valueOf(temp));
layout1.invalidate();
break;
case MotionEvent.ACTION_UP:
Log.d("onTouch (MySeekBar)", "Action Up");
toast.setVisibility(View.INVISIBLE);
toast2.setVisibility(View.VISIBLE);
toast3.setVisibility(View.VISIBLE);
touched = false;
break;
}// End of switch
return true;
}// End of onTouch
});
}// End of initialize
@Override
protected void onDraw(Canvas canvas) {
Log.d("onDraw (MySeekBar)", "onDraw");
super.onDraw(canvas);
if (initialized) {
thumb.layout(thumbLeft, thumbTop, thumbRight, thumbBottom);
Log.d("onDraw (MySeekBar)", "thumb layout: " + thumbLeft + ", "
+ thumbTop + ", " + thumbRight + ", " + thumbBottom);
int top = thumbTop - marginTop;
int left = thumbLeft + 4;
// toast.layout(left, top, left + toast.getWidth(), top +
// toast.getHeight());
top = thumbTop + thumb.getHeight() / 2 - toast2.getHeight() / 2 + 1;
left = thumbLeft;
toast2.layout(left, top, left + toast2.getWidth(),
top + toast2.getHeight());
}
}// End of onDraw
The 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="vertical"
android:id="@+id/test_layout">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<com.networksound.Mixer3.NewSeekBar
android:id="@+id/newSeekBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.NewSeekBar>
<com.networksound.Mixer3.NewSeekBar
android:id="@+id/newSeekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.NewSeekBar>
<com.networksound.Mixer3.MySeekBar
android:id="@+id/mySeekBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.MySeekBar>
<com.networksound.Mixer3.MySeekBar
android:id="@+id/mySeekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.MySeekBar>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<com.networksound.Mixer3.PanSeekBar
android:id="@+id/panSeekBar1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.PanSeekBar>
<com.networksound.Mixer3.PanSeekBar
android:id="@+id/panSeekBar2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.networksound.Mixer3.PanSeekBar>
</LinearLayout>
</LinearLayout>
If you're extending a ViewGroup
you should either override dispatchDraw()
instead of onDraw()
, or in the constructor, call setWillNotDraw(false)
. There's some discussion on it here.
这篇关于的onDraw()不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!