2

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>
Atara
  • 3,523
  • 6
  • 37
  • 56

2 Answers2

1

you can rotate the drawable like this

       <?xml version="1.0" encoding="utf-8"?>
   <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
  android:left="43dp"
  android:top="43dp"
  android:right="43dp"
  android:bottom="43dp">
  <rotate android:fromDegrees="45">
   <shape android:shape="oval">
    <size
     android:width="100dp"
     android:height="200dp" />
    <solid android:color="#6B35B7" />
   </shape>
    </rotate>
   </item>
  </layer-list>

change the rotation angle to 180 or any angle you want

B.mansouri
  • 376
  • 7
  • 16
  • Thanks, I added android:angle="@integer/rtl_mirror_flip" to my gradient. based on https://stackoverflow.com/questions/38383722/rotating-the-gradient-not-the-oval now it looks much better – Atara Jan 09 '19 at 14:49
0

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"
    />

Atara
  • 3,523
  • 6
  • 37
  • 56