如果/**
* Created by Shuvam Ghosh on 8/26/2017.
*/
public class IndicatorView extends View {
private RectF mRect;
private Paint mRectPaint;
private Paint mCirclePaint;
private int noOfTabs;
private Path triangle;
private PointF leftpt;
private PointF midpt;
private PointF rightpt;
private Bitmap [] imgRes;
private int [] resources;
private float defval = ((float)getWidth()/3)/2;
public IndicatorView(Context context) {
super(context);
init(null);
}
public IndicatorView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(attrs);
}
public void setResources(int [] res){
this.resources = res;
Log.d("Size of imgres",""+resources.length);
}
public IndicatorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(attrs);
}
public IndicatorView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(attrs);
}
public void init(@Nullable AttributeSet set){
resources = new int[noOfTabs];
mRect = new RectF();
mRect.left = 0;
mRect.top = 0;
mRect.bottom = 140;
triangle = new Path();
leftpt=new PointF();
midpt=new PointF();
rightpt=new PointF();
Log.d("Size of imgres in init",""+resources.length);
leftpt.x=0;
leftpt.y=0;
midpt.x=((float)getWidth())/2 ;
midpt.y=0;
rightpt.x=0;
rightpt.y=0;
//bmp = BitmapFactory.decodeResource(getResources(),R.drawable.ic_android_black_24dp);
mRectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mRectPaint.setColor(Color.parseColor("#e7ab33"));
mRectPaint.setStyle(Paint.Style.FILL);
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setColor(Color.GREEN);
if(set == null)
{
return;
}
TypedArray ta = getContext().obtainStyledAttributes(set , R.styleable.IndicatorView);
noOfTabs = ta.getInteger(R.styleable.IndicatorView_no_of_sections,3);
mCirclePaint.setColor(Color.WHITE);
ta.recycle();
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
mRect.right = getWidth();
canvas.drawRect(mRect,mRectPaint);
Log.d("No of tabs=",""+noOfTabs);
Log.d("X-axis value=",""+(2/(float)noOfTabs));
Log.d("midptx value=",""+midpt.x);
midpt.y = 168;
leftpt.x = midpt.x - 35;
leftpt.y = 140;
rightpt.x = midpt.x + 35;
rightpt.y = 140;
triangle.lineTo(leftpt.x, leftpt.y);
triangle.lineTo(midpt.x, midpt.y);
triangle.lineTo(rightpt.x,rightpt.y);
canvas.drawPath(triangle,mRectPaint);
Log.d("Size of imgres inOndraw",""+resources.length);
imgRes = new Bitmap[noOfTabs];
for(int i=0; i<resources.length; i++)
{
imgRes[i] = BitmapFactory.decodeResource(getResources(),resources[i]);
}
canvas.drawBitmap(imgRes[0],(getWidth()/noOfTabs)/2-(imgRes[0].getWidth()),70-(imgRes[0].getHeight())/2,null);
for(int i =1; i<noOfTabs; i++) {
// canvas.drawCircle((i / (float) noOfTabs) * getWidth(), 66, 6, mCirclePaint);
canvas.drawBitmap(imgRes[i],(i / (float) noOfTabs) * getWidth()+(getWidth()/noOfTabs)/2-(imgRes[i].getWidth()/2),70-(imgRes[i].getHeight())/2,null);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// return super.onTouchEvent(event);
int eventAction = event.getAction();
// you may need the x/y location
int x = (int)event.getX();
int y = (int)event.getY();
// put your code in here to handle the event
switch (eventAction) {
case MotionEvent.ACTION_DOWN:
drawNewArrow();
midpt.x = x;
Log.d("Touched at",""+(x*3)/getWidth());
invalidate();
break;
case MotionEvent.ACTION_UP:
break;
case MotionEvent.ACTION_MOVE:
break;
}
// postInvalidate();
return false;
}
}
在对话框中且VirtualKeyboard
是基类,则无法点击TextField
。
以下是代码:
Application Window
如果我将 ApplicationWindow 更改为窗口,则不会出现问题,这是否是 v5.9.1 中的QT错误?
答案 0 :(得分:0)
ApplicationWindow
提供了一个很好的额外图层overlay
,您可以将其重新显示在内容其余部分之上的所有内容 - 恰好是VirtualKeyboard
InputPanel {
id: inputPanel
parent: ApplicationWindow.overlay // <-- This will do the trick
anchors.bottom:parent.bottom
anchors.left: parent.left
anchors.right: parent.right
visible: Qt.inputMethod.visible
}