Yalantis / Context-Menu.Android

You can easily add awesome animated context menu to your app.

Home Page:https://yalantis.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how can i change position dialog in left side ?

joShinichi opened this issue · comments

hi...i used your library and that was awesome...
but my question is, can i customize the dialog position to the left side ?

thanks and best regards....

Hi, @joShinichi! Thank you for reporting this issue.
Now, this lib is designed in the way to be displayed on the right/end side of the screen. And there is no ability to customize its position.

I got it, all you need is change these files

  • fragment_menu.xml
    `

      <LinearLayout
          android:id="@+id/wrapper_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="@dimen/text_wrapper_right_margin"
          android:layout_marginStart="@dimen/text_wrapper_right_margin"
          android:layout_toEndOf="@+id/wrapper_buttons"
          android:layout_toRightOf="@+id/wrapper_buttons"
          android:gravity="start"
          android:orientation="vertical" />
    
      <LinearLayout
          android:id="@+id/wrapper_buttons"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:orientation="vertical" />
    

`

  • MenuAdapter.java change resetSideAnimation(View view)
    private void resetSideAnimation(View view) { if (!mIsMenuOpen) { ViewHelper.setRotation(view, 0); ViewHelper.setRotationY(view, -90); ViewHelper.setRotationX(view, 0); } ViewHelper.setPivotX(view, 0); ViewHelper.setPivotY(view, mMenuItemSize / 2); }

  • AnimatorUtils.java change rotationCloseToRight(View v) and rotationOpenFromRight(View v)
    `public static ObjectAnimator rotationCloseToLeft(View v) {
    return ObjectAnimator.ofFloat(v, "rotationY", 0, 90);
    }

    public static ObjectAnimator rotationOpenFromLeft(View v) {
    return ObjectAnimator.ofFloat(v, "rotationY", 90, 0);
    }`

And change the dimens file

<dimen name="text_wrapper_right_margin">8dp</dimen>

just add this in Manifest

android:supportsRtl="false" -> open from right
android:supportsRtl="true" -> open from left

commented

Gravity added, check readme