Solve the Problem of Blank Up and down ImageView.
Today, when I was doing an application, I found that there was a blank space in the upper and lower part of the ImageView, so I knew this attribute:
android:adjustViewBounds="true"
If you want to add it, it means whether to maintain the aspect ratio. If you want to use maxWidth and MaxHeight together on the internet, otherwise it will be ineffective to use it separately. However, I have set another attribute.
android:cropToPadding
Specifies whether to intercept the specified area and use blank space instead. The setting is ineffective and must be used with scrollY:
The following is an XMl property map:
In Android, how can I remove the image edge blank?
In PNG format, use PS to make the blank space you don't want transparent.
In android, how does one set a slide event between top, bottom, and left?
Private float mPosX;
Private float mPosY;
Private float mCurrentPosX;
Private float mCurrentPosY;
Private ImageView imageview;
@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. activity_main );
Imageview = (ImageView) findViewById (R. id. imageview );
Imageview. setOnTouchListener (new View. OnTouchListener (){
@ Override
Public boolean onTouch (View v, MotionEvent event ){
Switch (event. getAction ()){
// Press
Case MotionEvent. ACTION_DOWN:
MPosX = event. getX ();
MPosY = event. getY ();
Break;
// Move
Case MotionEvent. ACTION_MOVE:
MCurrentPosX = event. getX ();
MCurrentPosY = event. getY ();
If (mCurrentPosX-mPosX> 0 & Math. abs (mCurrentPosY-mPosY) <10)
Log. e ("", "right ");
Else if (mCurrentPosX-mPosX <0 & Math. abs (mCurrentPosY-mPosY) <10)
Log. e ("", "Left ");
Else if (mCurrentPosY-mPosY> 0 & Math. abs (mCurrentPosX-mPosX) <10)
Log. e ("", "down ");
Else if (mCurrentPosY-mPosY <0 & Math. abs (mCurrentPosX-mPosX) <10)
Log. e ("", "up ");
Break;
// Pick up
Case MotionEvent. ACTION_UP:
Break;
Default:
Break;
}
Return true;
}
});
}... Remaining full text>