androidright-to-leftslidingmenu

How to adjust shadow to RTL SlidingMenu


I need to adjust working LTR application into supporting RTL.

among other things, I changed the slidingMenu to open from RIGHT, but it looks like its shadow is not in the correct place.

How do I adjust the shadow position?

relevant code:

    menu = new SlidingMenu(this);
    boolean isRtl = getResources().getBoolean(R.bool.is_rtl);
    if (isRtl) {
        menu.setMode(SlidingMenu.RIGHT);
    } else {
        menu.setMode(SlidingMenu.LEFT);
    }

    // Set the touch screen mode
    menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    menu.setShadowWidthRes(R.dimen.shadow_width); // 
    menu.setShadowDrawable(R.drawable.shadow);

    menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    menu.setFadeDegree(0.35f);
    menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
    menu.setMenu(R.layout.activity_home_leftmenu);

dimen:

....
<dimen name="slidingmenu_offset">100dp</dimen>
<dimen name="shadow_width">15dp</dimen>

shadow:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <gradient
        android:endColor="#33000000"
        android:centerColor="#11000000"
        android:startColor="#00000000" />

</shape>

Solution

  • I added rotation angle based on Rotating the gradient not the oval and on android determine if device is in right to left language/layout

    <gradient
        android:endColor="#33000000"
        android:centerColor="#11000000"
        android:startColor="#00000000"
        android:angle="@integer/rtl_mirror_flip"
        />