コード例 #1
0
        /// <summary>
        /// @brief This method is used when layout direction was changed from RTL to LTR or LTR to RTL
        /// </summary>
        /// <param name="alignment"> int
        /// @return </param>
        protected internal virtual RelativeLayout.LayoutParams prepareLayoutParams(int alignment)
        {
            RelativeLayout.LayoutParams @params = (RelativeLayout.LayoutParams) this.LayoutParams;
            @params.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
            @params.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            @params.removeRule(RelativeLayout.ALIGN_PARENT_LEFT);
            @params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            switch (alignment)
            {
            case ALIGN_PARENT_TOP_LEFT:
                @params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                @params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                changeLayoutDirection(LAYOUT_DIRECTION_RTL);
                break;

            case ALIGN_PARENT_TOP_RIGHT:
                @params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                @params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                changeLayoutDirection(LAYOUT_DIRECTION_LTR);
                break;

            case ALIGN_PARENT_BOTTOM_LEFT:
                @params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                @params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                changeLayoutDirection(LAYOUT_DIRECTION_RTL);
                break;

            case ALIGN_PARENT_BOTTOM_RIGHT:
                @params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                @params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                changeLayoutDirection(LAYOUT_DIRECTION_LTR);
                break;

            default:
                @params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
                @params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
                changeLayoutDirection(LAYOUT_DIRECTION_RTL);
                break;
            }

            return(@params);
        }