寻找条形图来调整1到20像素的边框大小?

时间:2016-08-23 06:56:13

标签: java android xml

这是我的代码,我可以使用seekbar调整图像大小。但是我将imageview的边框设置为红色,我想使用搜索栏调整imageview的边框... plz帮我怎么做? Thnx提前......

private static final int CAMERA_REQUEST = 1888;
private ImageView imageview;
SeekBar sb;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    sb = (SeekBar) findViewById(R.id.seekbar1);
    sb.setMax(708);
    sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        int progressChangedValue = 0;

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress,
                                      boolean fromUser) {
            progressChangedValue = progress;
            imageview.getLayoutParams().width = progress;
            imageview.getLayoutParams().height = progress;
            imageview.requestLayout();
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
            Toast.makeText(MainActivity.this, "progress starts",
                    Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
            Toast.makeText(MainActivity.this, "Seek bar progress is :" + progressChangedValue,
                    Toast.LENGTH_SHORT).show();
        }

    });

    imageview = (ImageView)findViewById(R.id.imageview1);
    imageview.setBackgroundResource(R.drawable.sty);
    Button photoButton = (Button) this.findViewById(R.id.button1);

    assert photoButton != null;
    photoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);

        }
    });
}

protected void onActivityResult(int requestcode, int resultcode, Intent data) {
    if (requestcode == CAMERA_REQUEST && resultcode == RESULT_OK) {

        Bitmap photo = (Bitmap) data.getExtras().get("data");
        imageview.setImageBitmap(photo);
      }
   }
}

0 个答案:

没有答案