Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 可用于数字切纸机的复合拉丝机_Android_Custom Controls_Android Ui_Android Custom View_Numberpicker - Fatal编程技术网

Android 可用于数字切纸机的复合拉丝机

Android 可用于数字切纸机的复合拉丝机,android,custom-controls,android-ui,android-custom-view,numberpicker,Android,Custom Controls,Android Ui,Android Custom View,Numberpicker,我正在试着为我的定制号码牌画一幅复合画。我发现主视图实际上是一个EditText,并且由于EditText有复合可绘制项(DrawableLeft、DrawableRight等),我尝试设置它,但是当NumberPicker实际出现时,它就不存在了。还有什么我可以试着去做的吗 我目前的代码- public class ViewPicker extends NumberPicker { private int textSize = -1; public ViewPicker(Co

我正在试着为我的定制号码牌画一幅复合画。我发现主视图实际上是一个EditText,并且由于EditText有复合可绘制项(DrawableLeft、DrawableRight等),我尝试设置它,但是当NumberPicker实际出现时,它就不存在了。还有什么我可以试着去做的吗

我目前的代码-

public class ViewPicker extends NumberPicker {
    private int textSize = -1;

    public ViewPicker(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // TODO Auto-generated constructor stub
    }

    public ViewPicker(Context context, AttributeSet attrs) {
        super(context, attrs);
        // TODO Auto-generated constructor stub
    }

    public ViewPicker(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
    }

    @Override
    public void addView(View child) {
        super.addView(child);
        updateView(child);
    }

    @Override
    public void addView(View child, int index,
            android.view.ViewGroup.LayoutParams params) {
        super.addView(child, index, params);
        updateView(child);
    }

    @Override
    public void addView(View child, android.view.ViewGroup.LayoutParams params) {
        super.addView(child, params);
        updateView(child);
    }

    private void updateView(View view) {
        if (view instanceof EditText) {
            EditText editText = (EditText) view;
            if (textSize > 0)
                editText.setTextSize(textSize);
            editText.setTextColor(Color.parseColor("#333333"));

            Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);

            BitmapDrawable draw = new BitmapDrawable(getResources(),bitmap);

            editText.setCompoundDrawables(draw, null, null, null);
        }
    }

    public int getTextSize() {
        return textSize;
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
    }
}

让我知道是否有其他方法可用于此操作。

我只是尝试完成同样的事情。我面临的是同样的问题,只需使用SetCompoundDrawableswithInInsitCBounds,就像您使用无界DrawableswithInInsitCBounds一样