开发者

Change image width on Java

Hi I added this comment to the code to show a background when i press , but it show the image all is working except , the image is too small , but the image size correspond on the size of the device , how can i set the size , or force it to be

setBackgroundResource(R.drawable.slider_bg);

there is the full code

switch (action) {
    case MotionEvent.ACTION_DOWN: {
        mTracking = true;
        mTriggered = false;
        vibrate();
        if (leftHit) {
            mCurrentSlider = mLeftSlider;
            mOtherSlider = mRightSlider;
            mThreshold = isHorizontal() ? THRESHOLD : 1.0f - THRESHOLD;
            setGrabbedState(OnTriggerListener.LEFT_HANDLE);
            setBackgroundResource(R.drawable.slider_bg_right);
        } else {
            mCurrentSlider = mRightSlider;
            mOtherSlider = mLeftSlider;
            mThreshold = isHorizontal() ? 1.0f - THRESHOLD : THRESHOLD;
            setGr开发者_如何学JAVAabbedState(OnTriggerListener.RIGHT_HANDLE);
            setBackgroundResource(R.drawable.slider_bg_left);
        }                  
        mCurrentSlider.setState(Slider.STATE_PRESSED);
        mCurrentSlider.showTarget();
        mOtherSlider.hide();
        break;
    }
}

cheers


I'll post you a small example, feel free to adjust to your needs:

int width = 1024;
int height = 768;
FrameLayout fl = (FrameLayout) findViewById(R.id.mainframe);

fl.setLayoutParams(new FrameLayout.LayoutParams(width, height));

If you want you can use match_parrent instead of width and height ofc, or anything else that xml can do

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜