安卓:$向左p $ pferencescreen权 [英] Android : preferencescreen right to left

查看:231
本文介绍了安卓:$向左p $ pferencescreen权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是preferenceScreen的xml文件
因为我需要preferenceCategory出现RTL,但l其他compnents出现LTR
如何使thim RTL?

我绑遵循这一链接和我说的android:supportsRtl =真的元素在我的清单文件,但没有发生

 <?XML版本=1.0编码=UTF-8&GT?;
< preferenceScreen的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =WRAP_CONTENT
    机器人:重力=结束>    < preferenceScreen
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:标题=@字符串/ about_feedex>
            <意向
                机器人:行动=android.intent.action.VIEW
                机器人:targetPackage =com.arrafni.news
                机器人:targetClass =com.arrafni.news.activity.AboutActivity/>
    < / preferenceScreen>    < preferenceCategory
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:重力=结束
        机器人:标题=@字符串/ settings_category_refresh>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:设置defaultValue =真
            机器人:键=refresh.enabled
            机器人:总结=@字符串/ settings_refresh_enabled_description
            机器人:标题=@字符串/ settings_refresh_enabled/>        <名单preference
            机器人:名字=@字符串/ settings_refresh_interval
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:设置defaultValue =1800000
            机器人:依赖=refresh.enabled
            机器人:项=@阵列/ settings_intervals
            机器人:entryValues​​ =@阵列/ settings_interval_values​​
            安卓的inputType =数字
            机器人:键=refresh.interval
            机器人:总结=@字符串/ settings_refresh_interval_description
            机器人:标题=@字符串/ settings_refresh_interval/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:设置defaultValue =假
            机器人:键=refreshonopen.enabled
            机器人:总结=@字符串/ settings_refresh_on_open_description
            机器人:标题=@字符串/ settings_refresh_on_open/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =假
            机器人:重力=结束
            机器人:键=refreshwifionly.enabled
            机器人:总结=@字符串/ settings_refresh_wifi_only_description
            机器人:标题=@字符串/ settings_refresh_wifi_only/>
    < / preferenceCategory>    < preferenceCategory
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:标题=@字符串/ settings_category_content_ presentation>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =真
            机器人:重力=结束
            机器人:disableDependentsState =真
            机器人:键=lighttheme
            机器人:总结=@字符串/ settings_lighttheme_description
            机器人:标题=@字符串/ settings_lighttheme/>        <名单preference
            机器人:名字=@字符串/ settings_keep_time
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =4
            机器人:重力=结束
            机器人:项=@阵列/ settings_keep_times
            机器人:entryValues​​ =@阵列/ settings_keep_time_values​​
            安卓的inputType =数字
            机器人:键=香港凯泰
            机器人:总结=@字符串/ settings_keep_time_description
            机器人:标题=@字符串/ settings_keep_time/>        <名单preference
            机器人:名字=@字符串/ settings_font_size
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =0
            机器人:重力=结束
            机器人:项=@阵列/ settings_font_sizes
            机器人:entryValues​​ =@阵列/ settings_font_size_values​​
            安卓的inputType =数字
            机器人:键=字号
            机器人:总结=@字符串/ settings_font_size_description
            机器人:标题=@字符串/ settings_font_size/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =假
            机器人:重力=结束
            机器人:disableDependentsState =真
            机器人:键=pictures.disable
            机器人:总结=@字符串/ settings_disable_pictures_description
            机器人:标题=@字符串/ settings_disable_pictures/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =假
            机器人:重力=结束
            机器人:依赖=pictures.disable
            机器人:键=pictures.fetch
            机器人:总结=@字符串/ settings_fetch_pictures_description
            机器人:标题=@字符串/ settings_fetch_pictures/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =假
            机器人:重力=结束
            机器人:键=display_oldest_first
            机器人:总结=@字符串/ settings_display_oldest_first_description
            机器人:标题=@字符串/ settings_display_oldest_first/>
    < / preferenceCategory>    < preferenceCategory
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:重力=结束
        机器人:标题=@字符串/ settings_category_notifications>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:设置defaultValue =真
            机器人:重力=结束
            机器人:键=notifications.enabled
            机器人:总结=@字符串/ settings_notifications_enabled_description
            机器人:标题=@字符串/ settings_notifications_enabled/>        <铃声preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:依赖=notifications.enabled
            机器人:键=notifications.ringtone
            机器人:ringtoneType =通知
            机器人:总结=@字符串/ settings_notifications_ringtone_description
            机器人:标题=@字符串/ settings_notifications_ringtone/>        <复选框preference
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:依赖=notifications.enabled
            机器人:重力=结束
            机器人:键=notifications.vibrate
            机器人:总结=@字符串/ settings_notifications_vibrate_description
            机器人:标题=@字符串/ settings_notifications_vibrate/>
    < / preferenceCategory>    < preferenceCategory
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:重力=结束
        机器人:textDirection =RTL
        机器人:标题=@字符串/ settings_category_network>        < preferenceScreen
            机器人:layout_width =WRAP_CONTENT
            机器人:layout_height =WRAP_CONTENT
            机器人:重力=结束
            机器人:textDirection =RTL
            机器人:标题=@字符串/ settings_screen_proxy>            <复选框preference
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:重力=结束
                机器人:textDirection =RTL
                机器人:键=proxy.enabled
                机器人:标题=@字符串/ settings_proxy_enabled/>            <复选框preference
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:重力=结束
                机器人:textDirection =RTL
                机器人:依赖=proxy.enabled
                机器人:键=proxy.wifionly
                机器人:总结=@字符串/ settings_proxy_wifi_only_description
                机器人:标题=@字符串/ settings_proxy_wifi_only/>            < EditText上preference
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:重力=结束
                机器人:textDirection =RTL
                机器人:依赖=proxy.enabled
                机器人:键=proxy.host
                机器人:标题=@字符串/ settings_proxy_host/>            < EditText上preference
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:依赖=proxy.enabled
                机器人:重力=结束
                机器人:textDirection =RTL
                安卓的inputType =数字
                机器人:键=proxy.port
                机器人:标题=@字符串/ settings_proxy_port/>            <名单preference
                机器人:名字=@字符串/ settings_proxy_type
                机器人:layout_width =WRAP_CONTENT
                机器人:layout_height =WRAP_CONTENT
                机器人:textDirection =RTL
                机器人:重力=结束
                机器人:设置defaultValue =0
                机器人:依赖=proxy.enabled
                机器人:项=@阵列/ settings_proxy_types_names
                机器人:entryValues​​ =@阵列/ settings_proxy_types
                安卓的inputType =数字
                机器人:键=proxy.type
                机器人:标题=@字符串/ settings_proxy_type/>
        < / preferenceScreen>
    < / preferenceCategory>< / preferenceScreen>


解决方案

你有没有解决了这个?

有这2个可能的解决方法:延长每个preferences的,并添加:

  @TargetApi(Build.VERSION_ codeS.JELLY_BEAN_MR1)
  @覆盖
  受保护的视图onCreateView(最终的ViewGroup paramViewGroup)
    {
    最后查看视图= super.onCreateView(paramViewGroup);
    如果(VERSION.SDK_INT> = VERSION_ codeS.JELLY_BEAN_MR1)
      view.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
    返回视图。
    }

另一个更简单的是上的活动:

 如果(VERSION.SDK_INT> = VERSION_ codeS.JELLY_BEAN_MR1)
  。getListView()setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);

不过,对于这两种解决方法我找不到如何处理对话框正在显示由pressing一些preferences。

This is the xml file of PreferenceScreen the PreferenceCategory appears RTL as I need, but L other compnents Appear LTR How to make thim RTL ?

I tied to follow this link and I added android:supportsRtl="true" to the element in my manifest file but nothing happened !

 <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="end">

    <PreferenceScreen
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:title="@string/about_feedex">
            <intent
                android:action="android.intent.action.VIEW"
                android:targetPackage="com.arrafni.news"
                android:targetClass="com.arrafni.news.activity.AboutActivity"/>
    </PreferenceScreen>

    <PreferenceCategory
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:title="@string/settings_category_refresh">

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:defaultValue="true"
            android:key="refresh.enabled"
            android:summary="@string/settings_refresh_enabled_description"
            android:title="@string/settings_refresh_enabled" />

        <ListPreference
            android:name="@string/settings_refresh_interval"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:defaultValue="1800000"
            android:dependency="refresh.enabled"
            android:entries="@array/settings_intervals"
            android:entryValues="@array/settings_interval_values"
            android:inputType="number"
            android:key="refresh.interval"
            android:summary="@string/settings_refresh_interval_description"
            android:title="@string/settings_refresh_interval" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:defaultValue="false"
            android:key="refreshonopen.enabled"
            android:summary="@string/settings_refresh_on_open_description"
            android:title="@string/settings_refresh_on_open" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="false"
            android:gravity="end"
            android:key="refreshwifionly.enabled"
            android:summary="@string/settings_refresh_wifi_only_description"
            android:title="@string/settings_refresh_wifi_only" />
    </PreferenceCategory>

    <PreferenceCategory
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:title="@string/settings_category_content_presentation">

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="true"
            android:gravity="end"
            android:disableDependentsState="true"
            android:key="lighttheme"
            android:summary="@string/settings_lighttheme_description"
            android:title="@string/settings_lighttheme" />

        <ListPreference
            android:name="@string/settings_keep_time"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="4"
            android:gravity="end"
            android:entries="@array/settings_keep_times"
            android:entryValues="@array/settings_keep_time_values"
            android:inputType="number"
            android:key="keeptime"
            android:summary="@string/settings_keep_time_description"
            android:title="@string/settings_keep_time" />

        <ListPreference
            android:name="@string/settings_font_size"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="0"
            android:gravity="end"
            android:entries="@array/settings_font_sizes"
            android:entryValues="@array/settings_font_size_values"
            android:inputType="number"
            android:key="fontsize"
            android:summary="@string/settings_font_size_description"
            android:title="@string/settings_font_size" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="false"
            android:gravity="end"
            android:disableDependentsState="true"
            android:key="pictures.disable"
            android:summary="@string/settings_disable_pictures_description"
            android:title="@string/settings_disable_pictures" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="false"
            android:gravity="end"
            android:dependency="pictures.disable"
            android:key="pictures.fetch"
            android:summary="@string/settings_fetch_pictures_description"
            android:title="@string/settings_fetch_pictures" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="false"
            android:gravity="end"
            android:key="display_oldest_first"
            android:summary="@string/settings_display_oldest_first_description"
            android:title="@string/settings_display_oldest_first" />
    </PreferenceCategory>

    <PreferenceCategory
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:title="@string/settings_category_notifications">

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:defaultValue="true"
            android:gravity="end"
            android:key="notifications.enabled"
            android:summary="@string/settings_notifications_enabled_description"
            android:title="@string/settings_notifications_enabled" />

        <RingtonePreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:dependency="notifications.enabled"
            android:key="notifications.ringtone"
            android:ringtoneType="notification"
            android:summary="@string/settings_notifications_ringtone_description"
            android:title="@string/settings_notifications_ringtone" />

        <CheckBoxPreference
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:dependency="notifications.enabled"
            android:gravity="end"
            android:key="notifications.vibrate"
            android:summary="@string/settings_notifications_vibrate_description"
            android:title="@string/settings_notifications_vibrate" />
    </PreferenceCategory>

    <PreferenceCategory
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="end"
        android:textDirection = "rtl"
        android:title="@string/settings_category_network">

        <PreferenceScreen
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="end"
            android:textDirection = "rtl"
            android:title="@string/settings_screen_proxy">

            <CheckBoxPreference
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="end"
                android:textDirection = "rtl"
                android:key="proxy.enabled"
                android:title="@string/settings_proxy_enabled" />

            <CheckBoxPreference
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="end"
                android:textDirection = "rtl"
                android:dependency="proxy.enabled"
                android:key="proxy.wifionly"
                android:summary="@string/settings_proxy_wifi_only_description"
                android:title="@string/settings_proxy_wifi_only" />

            <EditTextPreference
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="end"
                android:textDirection = "rtl"
                android:dependency="proxy.enabled"
                android:key="proxy.host"
                android:title="@string/settings_proxy_host" />

            <EditTextPreference
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:dependency="proxy.enabled"
                android:gravity="end"
                android:textDirection = "rtl"
                android:inputType="number"
                android:key="proxy.port"
                android:title="@string/settings_proxy_port" />

            <ListPreference
                android:name="@string/settings_proxy_type"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textDirection = "rtl"
                android:gravity="end"
                android:defaultValue="0"
                android:dependency="proxy.enabled"
                android:entries="@array/settings_proxy_types_names"
                android:entryValues="@array/settings_proxy_types"
                android:inputType="number"
                android:key="proxy.type"
                android:title="@string/settings_proxy_type" />
        </PreferenceScreen>
    </PreferenceCategory>

</PreferenceScreen>

解决方案

Have you solved this?

There are 2 possible workarounds for this: extend each of the preferences, and add :

  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
  @Override
  protected View onCreateView(final ViewGroup paramViewGroup)
    {
    final View view=super.onCreateView(paramViewGroup);
    if(VERSION.SDK_INT>=VERSION_CODES.JELLY_BEAN_MR1)
      view.setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);
    return view;
    }

another easier one is on the activity:

if(VERSION.SDK_INT>=VERSION_CODES.JELLY_BEAN_MR1)
  getListView().setLayoutDirection(View.LAYOUT_DIRECTION_LOCALE);

However, for both workarounds I can't find how to handle the dialogs being shown by pressing on some preferences.

这篇关于安卓:$向左p $ pferencescreen权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆