Solve the Problem of Blank Up and down ImageView.

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.