How to right align PreferencesActivity in android?

前端 未结 14 2252
一向
一向 2020-12-31 07:07

I have PreferencesActivity which I need it to be right aligned because I want to use Arabic language, I tried to use android:layout_gravity=\"right\"

14条回答
  •  滥情空心
    2020-12-31 07:44

    This method worked for me:

            @Override
    public View onCreateView(View parent, String name, Context context, AttributeSet attrs)
    {
        View v = super.onCreateView(parent, name, context, attrs);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
        {
            if(parent != null)
                parent.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
            if(v != null)
                v.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
        }
        return v;
    }
    

提交回复
热议问题