In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the android how to achieve poker card flip related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this android how to achieve poker card flip article will have a harvest, let's take a look.
One additional point to note: this is a problem that has just been discovered. In the main activity, the xml file on the front and back will give priority to the default display of that xml file, so if I need to see the front side of the app as soon as I open it, then the front xml file needs to be placed under the negative xml file, that is
Following the logical line of the code, there are the next two layout:
These two FrameLayout also need to write id, which will be used later.
Cell_card_back.xml:
Cell_card_front.xml:
To continue to follow the logical lines of the above two layouts, you need to use two Drawable files as background images, so move on to the drawable file:
Rectangle_back.xml:
It's probably a card interface with a black edge, red background and rounded corners.
Rectangle_front.xml:
It's probably a black-edged, gray-background card interface with rounded corners.
After walking through the logic line of the interface UI, I went to look at the Java code and found that two Animator were needed, so create an animator resource folder under the res file, and create two animation files under:
Anim-in.xml:
This is an animation entered from the left, which is hidden at first, rotates in the opposite direction, and displays the card when it is halfway around.
Anim_out.xml:
This is an animation that goes out on the right, rotates 180 degrees, and when it is halfway around, the card disappears.
Then take a look at the Java code:
MainActivity:
Public class MainActivity extends AppCompatActivity {@ Bind (R.id.main_fl_card_back) FrameLayout mFlCardBack; @ Bind (R.id.main_fl_card_front) FrameLayout mFlCardFront; @ Bind (R.id.main_fl_container) FrameLayout mFlContainer; private AnimatorSet mLeftInSet; private AnimatorSet mRightOutSet; private boolean mIsShowBack; @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main) ButterKnife.bind (this); setAnimation (); / / set setCameraDistance (); / / set the lens distance, which I don't quite understand here} private void setAnimation () {/ / mLeftInSet is the animation mLeftInSet = (AnimatorSet) AnimatorInflater.loadAnimator (this, R.animator.anim_in) entered on the left. / / mRightOutSet is the animation coming out on the right mRightOutSet = (AnimatorSet) AnimatorInflater.loadAnimator (this, R.animator.anim_out) / / Click the event / / you don't need to rewrite all the methods through ListenerAdapter, just write the method mRightOutSet.addListener (new AnimatorListenerAdapter () {/ / the animation starts @ Override public void onAnimationStart (Animator animation) {super.onAnimationStart (animation); mFlContainer.setClickable (false);}})) / / at the end of the animation, mLeftInSet.addListener (new AnimatorListenerAdapter () {@ Override public void onAnimationEnd (Animator animation) {super.onAnimationEnd (animation); mFlContainer.setClickable (true); / / framelayouy in the main layout allows you to click}}) } / / the comment on the post reads: change the viewing distance and get close to the screen private void setCameraDistance () {int distance = 16000; float scale = getResources (). GetDisplayMetrics (). Density*distance; mFlCardFront.setCameraDistance (scale); / / set the distance mFlCardBack.setCameraDistance (scale) / / set distance} / / this is the click method of the main Framelayout public void flipCard (View view) {/ / mIsShowBack can be understood as mutually exclusive, so animate boolean if (! mIsShowBack) {/ / right out in the front card interface mRightOutSet.setTarget (mFlCardFront); / / left in animation is set in the reverse card interface mLeftInSet.setTarget (mFlCardBack) / / start animation mRightOutSet.start (); mLeftInSet.start (); mIsShowBack = true;} else {/ / right-out animation is set in the card back interface mRightOutSet.setTarget (mFlCardBack); / / left-in animation is set in the card front interface mLeftInSet.setTarget (mFlCardFront); mRightOutSet.start () MLeftInSet.start (); mIsShowBack = false;}} / / this has never occurred to me that you can unbind ButterKnife protected void onDestroy () {super.onDestroy (); ButterKnife.unbind (this);}} in the onDestroy method. That's all for the article on "how android implements card flipping". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "android how to flip poker cards". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.