Learning notes: pull-down refreshed view and graph rotation, learning notes View

Source: Internet
Author: User

Learning notes: pull-down refreshed view and graph rotation, learning notes View

1. View displayed only in the drop-down list

Pull_to_refresh_header.xml

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"              android:id="@+id/pull_to_refresh_header"              android:orientation="vertical"              android:layout_width="match_parent"              android:layout_height="wrap_content"              android:background="#F3F3F3">    <RelativeLayout        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:paddingTop="23dp">        <LinearLayout 
       android:id="@+id/pull_to_refresh_view" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_centerHorizontal="true"> <TextView android:id="@+id/pull_to_refresh_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/pull_to_refresh_text" android:textColor="#777777" android:textSize="16sp"/> <TextView android:id="@+id/pull_to_refresh_update_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@string/pull_to_refresh_update_text" android:textColor="#999999" android:textSize="14sp"/> </LinearLayout> <ProgressBar android:id="@+id/pull_to_refresh_progress" android:layout_width="30dp" android:layout_height="30dp"
       android:layout_toLeftOf="@id/pull_to_refresh_view" android:layout_marginRight="22dp" android:layout_marginTop="5dp" android:indeterminate="true" android:indeterminateDrawable="@drawable/ic_loading_refresh" android:visibility="gone"/> <ImageView android:id="@+id/pull_to_refresh_image" android:layout_width="32dp" android:layout_height="32dp" android:layout_toLeftOf="@id/pull_to_refresh_view" android:layout_marginRight="20dp" android:layout_marginTop="5dp" android:src="@drawable/ic_refresh_down" android:scaleType="centerInside" android:contentDescription="@string/app_name"/> </RelativeLayout> <View android:layout_width="match_parent" android:layout_height="15dp"/></LinearLayout>

Ic_loading_refresh.xml

<?xml version="1.0" encoding="utf-8"?><rotate xmlns:android="http://schemas.android.com/apk/res/android"    android:drawable="@drawable/ic_loading"    android:fromDegrees="0"    android:toDegrees="360"    android:pivotX="50%"    android:pivotY="50%" />

1. the indeterminate attribute of ProgressBar indicates whether the process time is uncertain.

2. The yellow background is the Android Studio prompt. The first tip is that when the Text in LinearLayout is extended long enough, it will overlap with the ImageView. The actual effect is to overwrite the ImageView. Second, we recommend that you use toStartOf instead of toLeftOf, and use marginEnd instead of marginRight. The Cause and impact have not been fully understood yet.

 

Ii. animation of icon Rotation

private ImageView mPull_to_refresh_image;private RotateAnimation mFlipAnimation;...        mFlipAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,                RotateAnimation.RELATIVE_TO_SELF, 0.5f);        mFlipAnimation.setInterpolator(new LinearInterpolator());        mFlipAnimation.setDuration(250);        mFlipAnimation.setFillAfter(true);...mPull_to_refresh_image.startAnimation(mFlipAnimation);

 

1. constructor:

    public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue,            int pivotYType, float pivotYValue)

(1) The value of toDegrees-fromDegrees <0 indicates a clockwise rotation. This is tested by using different values. The right side of the horizontal line is 0 °, or 360 °, and the left side is 180 °, or-180 °.

(2) The pivotType is the pivot type, that is, the center of the rotation. RELATIVE_TO_SELF indicates the view itself. 0.5f indicates the half size of the view.

2. setInterpolator is used to set the speeder. LinearInterpolator is a constant speed accelerator, that is, playing an animation at a constant speed.

3. setDuration is used to set the animation duration in milliseconds.

4. setFillAfter: When the parameter is true, the view will remain in the final state after the animation is played. The default value is false, that is, after the animation is played, the view will return to the original state.

 

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.