0

In my project we have 2 Linearlayout inside layout file, we want increase/decrease height via touch up and down

enter image description here

Inside a layout I have a horizontal view for changing height of layout. This view is the second layout

Marat
  • 6,142
  • 6
  • 39
  • 67
sr_ farzad
  • 45
  • 1
  • 9

2 Answers2

1
  1. First Detect amount of area scrolled by view using Android listView find the amount of pixels scrolled
  2. Then set this scrolled height dynamically to the view Android set height and width of Custom view programmatically
Community
  • 1
  • 1
Akshay Tilekar
  • 1,910
  • 2
  • 12
  • 22
0

I could resolve the problem.complete code is :

public class MultiTouchListener implements View.OnTouchListener {


    private float mPrevX;
    private float mPrevY;

    public QuranActivity mainActivity;
    public MultiTouchListener(QuranActivity mainActivity1) {
        mainActivity = mainActivity1;
    }

    @Override
    public boolean onTouch(View view, MotionEvent event) {
        float currX,currY;
        int action = event.getAction();
        switch (action ) {
            case MotionEvent.ACTION_DOWN: {

                mPrevX = event.getX();
                mPrevY = event.getY();
                break;
            }

            case MotionEvent.ACTION_MOVE:
            {

                int w = mainActivity.getWindowManager().getDefaultDisplay().getWidth() - 100;
                int h = mainActivity.getWindowManager().getDefaultDisplay().getHeight() - 100;



                currX = event.getRawX();
                currY = event.getRawY();


               ViewGroup.MarginLayoutParams marginParams = new ViewGroup.MarginLayoutParams(view.getLayoutParams());


                //marginParams.topMargin = (int)(currY - mPrevY);


            /*    if(currX>w){
                    marginParams.leftMargin = (int)(currX - mPrevX)-100;
                }
                else {
                    marginParams.leftMargin = (int)(currX - mPrevX);
                }


                if(currY>h){
                    marginParams.rightMargin = (int)(currY - mPrevY)-100;
                }
                else {
                    marginParams.rightMargin = (int)(currY - mPrevY);
                }
*/




                marginParams.setMargins(0, (int)(currY - mPrevY),0, 0);
                RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(marginParams);
                view.setLayoutParams(layoutParams);

                Log.e("onTouch X",currX - mPrevX+"  " + "" );
                Log.e("onTouch Y",currY - mPrevY+"  " + "" );



                break;
            }



            case MotionEvent.ACTION_CANCEL:
                break;

            case MotionEvent.ACTION_UP:

                break;
        }

        return true;
    }
}
sr_ farzad
  • 45
  • 1
  • 9