如何右对齐preferencesActivity android系统中? [英] How to right align PreferencesActivity in android?

查看:471
本文介绍了如何右对齐preferencesActivity android系统中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

preferencesActivity ,我需要它是右对齐的,因为我想用阿拉伯语,我试图用机器人: layout_gravity =右 preferenceScreen ,但没有奏效。

这是我的XML:

 < preferenceScreen的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android机器人:layout_gravity =权与GT;
        < preferenceCategory机器人:标题=常规设置>
                <复选框preference
                        机器人:标题=全屏
                        安卓:设置defaultValue =假
                        机器人:总结=始终查看为全屏
                        机器人:关键=全屏preF/>
        < preference
                机器人:标题=报告错误
                机器人:摘要=对任何错误或错误时通知我们
                机器人:关键=错误/>
        < preference
                机器人:标题=关于
                机器人:总结=版本1.0.0
                机器人:关键=约/>
        < / preferenceCategory>
< / preferenceScreen>
 

这是我如何使用内部的XML preferencesActivity

 添加preferencesFromResource(R.layout preferences。);
 

解决方案

不幸的是,基地preference组件(<一href="http://developer.android.com/reference/android/$p$pference/$p$pferenceScreen.html">$p$pferenceScreen, preference 时,等)在一个相当不实施-configurable方式。它们被设计以特定的方式工作,并不十分定制

为了做到你想要什么,你可能会实现自己的版本preferenceScreen(或可能只是preference您使用诸如复选框preference种)。它的设计方式,当它膨胀的XML布局,它假设了很多关于他们的东西,并会处理这些(文字大小,填充,布局,包装等)。这是伟大的,如果你想让它看起来像默认的,但不是那么大,如果你需要调整这些配置。

(注:如果你不希望实现preferencescreen你可以只使用一个列表视图,并把它当作一个preference页然而,无论哪种方式,你基本上要实现自己的版本,$ P的$ pferences。)

(注2:根据我所看到的关于阿拉伯文字等问题,这是的可能的Andr​​oid是足够聪明,尽量向右默认对齐不过,我会感到惊讶,如果这是。情况下,不过,这是值得一试。)

对不起,我没有一个更好的答案给你。

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" for PreferenceScreen but it didn't work.

This is my XML:

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="right">
        <PreferenceCategory android:title="General Settings">
                <CheckBoxPreference
                        android:title="Full Screen"
                        android:defaultValue="false"
                        android:summary="Always view as Full Screen"
                        android:key="fullScreenPref" />
        <Preference
                android:title="Report Bugs"
                android:summary="Notify us for any Bugs or Errors"
                android:key="bugs"/>
        <Preference
                android:title="About"
                android:summary="Version 1.0.0"
                android:key="about"/>
        </PreferenceCategory>
</PreferenceScreen>

This is how I use the XML inside PreferencesActivity:

addPreferencesFromResource(R.layout.preferences);

解决方案

Unfortunately the base Preference components (PreferenceScreen, Preference, etc.) are implemented in a fairly non-configurable way. They are designed to work in a specific way and are not terribly customizable.

In order to do what you want, you will probably have to implement your own version of PreferenceScreen (or possible just the Preference types you are using such as CheckBoxPreference). The way it is designed, when it inflates XML layouts it assumes a lot of things about them and handles it for you (text size, padding, layout, wrapping, etc). This is great if you want it to look like the default, but not so great if you need to tweak these configurations.

(note: if you don't want to implement preferencescreen you could just use a listview and treat it as a preference page. However, either way you basically have to implement your own version of preferences.)

(note2: based on other questions I've seen about arabic text, it's POSSIBLE android is smart enough to try to right align it by default. However, I would be surprised if this was the case. Still, it's worth a try.)

Sorry I don't have a better answer for you.

这篇关于如何右对齐preferencesActivity android系统中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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