SlidingDrawer的改变对齐(左,右等)处理 [英] Changing alignment (left, right etc) of SlidingDrawer handle

查看:243
本文介绍了SlidingDrawer的改变对齐(左,右等)处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我已经看到了一些相关的问题,但没有答案,所以把这个出在奇数机会,有人已经做了一些相似或可以点我在正确的方向...)

(I've seen a few related questions but no answers so putting this out on the odd chance someone has done something similar or can point me in the right direction...)

标准Android SlidingDrawer(也亚历山德罗Crugnola的多方向变异这我使用)中心对齐手柄。有没有人实施了SlidingDrawer它提供了选择向左或向右对齐处理?..或人对如何去这个任何提示?

The standard Android SlidingDrawer (and also Alessandro Crugnola's multi-direction variant which I'm using) centre-aligns the handle. Has anyone implemented a SlidingDrawer which offers the option to right or left align the handle?.. or anyone have any tips on how to go about this?

推荐答案

工作了。在 mVertical 是真实情况的 onLayout(布尔变化,诠释L,INT T,INT R,INT B) SlidingDrawer(或任何SlidingDrawer您正在使用的变体)的方法,你应该找到$以下线c $ C ...

Worked it out. In the mVertical is true condition of the onLayout(boolean changed, int l, int t, int r, int b) method of SlidingDrawer (or whatever variant of SlidingDrawer you're using), you should find the following line of code...

handleLeft = (width - childWidth) / 2;

...其中中心对齐手柄。更改为...

... which centre-aligns the handle. Change this to...

handleLeft = l;

...左对齐所述手柄当滑动抽屉设置为滑动垂直(即,底到顶部或顶部至底部),或改变它以...

... to left-align the handle when the sliding drawer is set to slide vertical (i.e. bottom-to-top or top-to-bottom), or change it to...

handleLeft = r - handleWidth;

...右对齐手柄。

... to right-align the handle.

同样地,如果滑动抽屉设置为滑动的水平(即从右到左或右至左),在 mVertical 是假条件 onLayout(布尔变化,诠释L,INT T,INT R,INT b)方法,找到下面这行code ...

Likewise, if the sliding drawer is set to slide horizontal (i.e. right-to-left or right-to-left), in the mVertical is false condition of the onLayout(boolean changed, int l, int t, int r, int b) method, find the following line of code...

handleTop = (height - childHeight) / 2;

...并将其更改为...

... and change it to...

handleTop = t;

...顶部对齐手柄,或者...

... to top-align the handle, or...

handleTop = b - handleHeight;

...上下对齐的手柄。编码快乐!

... to bottom-align the handle. Happy coding!

这篇关于SlidingDrawer的改变对齐(左,右等)处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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