Skip to content

change to support righ to left #35

Open

Description

@pishguy

can any body help me how can i modify source code ti support right to left? reference is on this link, but i can't understand me how can i modify that:

@3llomi @abbasalim

private void maybeInitProperties(CircleImageView child, View dependency) {
        if (mStartYPosition == 0)
            mStartYPosition = (int) (dependency.getY());

        if (mFinalYPosition == 0)
            mFinalYPosition = (dependency.getHeight() / 2);

        if (mStartHeight == 0)
            mStartHeight = child.getHeight();

        if (mStartXPosition == 0)
            mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));

        if (mFinalXPosition == 0)
            mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);

        if (mStartToolbarPosition == 0)
            mStartToolbarPosition = dependency.getY();

        if (mChangeBehaviorPoint == 0) {
            mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
        }
    }

Activity

  1. 3llomi commented on May 29, 2017

    @3llomi

    @MahdiPishguy Hi,sorry for late
    here is my Full Code with support for Older APIs
    `private void maybeInitProperties(CircleImageView child, View dependency) {
    if (mStartYPosition == 0)
    mStartYPosition = (int) (dependency.getY());

        if (mFinalYPosition == 0)
            mFinalYPosition = (dependency.getHeight() / 2);
    
        if (mStartHeight == 0)
            mStartHeight = child.getHeight();
    
        if (mStartXPosition == 0)
            mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));
    
        if (mFinalXPosition == 0)
            if (Utilities.getLanguage(mContext).equals("العربية")) {
                if (Build.VERSION.SDK_INT < 17 && Utilities.getLanguage(mContext).equals("العربية"))
                    mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);
                else
                    mFinalXPosition = mContext.getResources().getDisplayMetrics().widthPixels - 50;
            } else
                mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);
    
        if (mStartToolbarPosition == 0)
            mStartToolbarPosition = dependency.getY();
    
        if (mChangeBehaviorPoint == 0) {
            mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
        }
    }`
    

    and here is the getLanguage method in Utilities Class
    public static String getLanguage(Context mContext) { Locale current = mContext.getResources().getConfiguration().locale; return current.getDisplayLanguage(); }

    you can replace "العربية" with your language

  2. pishguy commented on May 29, 2017

    @pishguy
    Author

    @3llomi how can i change code to force move avatar image to right?

    this code as:

    mFinalXPosition = mContext.getResources().getDisplayMetrics().widthPixels - 50;

    not work correctly

    please see this code:

        private void maybeInitProperties(CircleImageView child, View dependency) {
            if (mStartYPosition == 0)
                mStartYPosition = (int) (dependency.getY());
    
            if (mFinalYPosition == 0)
                mFinalYPosition = (dependency.getHeight() / 2);
    
            if (mStartHeight == 0)
                mStartHeight = child.getHeight();
    
            if (mStartXPosition == 0)
                mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));
    
            if (mFinalXPosition == 0)
                mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);                //else
    
            if (mStartToolbarPosition == 0)
                mStartToolbarPosition = dependency.getY();
    
            if (mChangeBehaviorPoint == 0) {
                mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
            }
        }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions