如何修改Notifation Action Button的Icon和Text的位置

在阿拉伯,波斯等RTL语言下,对于一些含有action buttonUI虽然app使用了android:supportsRtl属性,但是仅仅是action之间的位置发生翻转,而每个buttonIconText位置却没调换。

比如(下图所示)未接来电的systemui下拉通知栏的icontext位置没有调换


如果要调整其位置,可以通过setTextViewCompoundDrawables(int viewId, int left, int top, int right, int bottom)函数去实现想要的效果。

下面的修改是在波斯语、阿拉伯语下把action button的图片放到文字的右边。

Import java.util.Lcoale;

Notification.javaalps\frameworks\base\core\java\android\app

  private RemoteViews generateActionButton(Action action) {

            final boolean tombstone = (action.actionIntent == null);

            RemoteViews button = new RemoteViews(mContext.getPackageName(),

                    tombstone ? R.layout.notification_action_tombstone

                              : R.layout.notification_action);

                   //modify

                   String language = Locale.getDefault().getLanguage();

                   if(language.equals("ar")||language.equals("fa")){

                      button.setTextViewCompoundDrawables(R.id.action0, 0, 0,action.icon, 0);

                    }else{

                      button.setTextViewCompoundDrawables(R.id.action0, action.icon, 0, 0, 0);

                    }

                   //modify

          ……

如果在其他地方要修改Button或者TextViewimagetext的位置,可以直接调用TextView的函数setCompoundDrawables(Drawable left, Drawable top,Drawable right, Drawable bottom)就行。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值