Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

background_unable无效 #25

Closed
LLQQHH opened this issue Jan 24, 2019 · 10 comments
Closed

background_unable无效 #25

LLQQHH opened this issue Jan 24, 2019 · 10 comments

Comments

@LLQQHH
Copy link

LLQQHH commented Jan 24, 2019

在xml里面设置android:enabled="false",然后设置background_unable 无效,但是代码中设置
RLinearLayout rLinearLayoutF = (RLinearLayout) findViewById(R.id.rLinearLayoutF);
rLinearLayoutF.setEnabled(false);有效
image

@LLQQHH
Copy link
Author

LLQQHH commented Jan 24, 2019

原生的ViewGroup好像也有这个bug

@LLQQHH
Copy link
Author

LLQQHH commented Jan 24, 2019

改成RTextView就没有问题!

@RuffianZhong
Copy link
Owner

@LLQQHH
久等了,最近太忙。这个问题已经处理了(麻烦升级到最新版本)
ViewGroup xml中enabled属性是无效的,java代码setEnabled()最终调用的是View的方法。
本库添加了了自定义属性:app:enabled="false" 解决ViewGroup中android:enabled="false"无效的问题
对于ViewGroup级别的可以使用自定义属性(app:enabled="false"
对于View级别的可以使用原生的属性(android:enabled="false"),也可以使用自定义属性

@scsfwgy
Copy link
Contributor

scsfwgy commented Aug 15, 2019

动态设置mView.setEnabled(false) view不会显示backgroundColorUnable的颜色,而是还是显示backgroundColorNormal的颜色。我看RTextViewHelpder下面的逻辑没有设置backgroundColorUnable的颜色。RBaseHelper#setup()也只是在初始化的时候设置一下。你看一下是否逻辑有问题?

/** * 设置是否启用 * * @param enabled */ public void setEnabled(boolean enabled) { if (enabled) { if (mIconNormal != null) { mIcon = mIconNormal; setIcon(); } } else { if (mIconUnable != null) { mIcon = mIconUnable; setIcon(); } } }

@scsfwgy
Copy link
Contributor

scsfwgy commented Aug 15, 2019

@RuffianZhong

@RuffianZhong
Copy link
Owner

RuffianZhong commented Aug 15, 2019

@scsfwgy
您是使用的时候不能正确显示?
我测试了一下,都是能够正常使用的
<com.ruffian.library.widget.RLinearLayout android:id="@+id/view_group" android:layout_height="50dp" android:layout_width="match_parent" app:background_normal="@color/colorPrimary" app:background_pressed="@color/colorPrimaryDark" app:background_unable="@color/purple" />
1.如果在代码中动态设置 直接 mViewGroup.setEnabled(false);
2.如果在xml中设置某个控件不可点击,则使用自定义属性(ViewGroup的特殊性,所以提供此属性)
app:enabled="false"

@LLQQHH
Copy link
Author

LLQQHH commented Aug 15, 2019

我也可以正常使用

@scsfwgy
Copy link
Contributor

scsfwgy commented Aug 15, 2019

我用的是RTextview,目的是:当正常时显示app:background_normal 颜色;当正在操作时,设置.setEnabled(false)这个时候不能点击,同时显示app:background_unable的颜色。
动态设置无效。

@LLQQHH
Copy link
Author

LLQQHH commented Aug 15, 2019

我是xml里面事先把不可点击的状态背景先设置好了,没有在代码里面设置

@RuffianZhong
Copy link
Owner

RuffianZhong commented Aug 15, 2019

@scsfwgy
正如 @LLQQHH 所说,你可以直接在xml中设置好各种状态的颜色值,在代码中只需要设置enabled=false 就好了呀,这正是使用这个控件方便之处。

同时如果你非要在代码中设置也是可以的,下面是我测试代码(测试没有问题):
mView.setEnabled(false); mView.getHelper().setBackgroundColorUnable(getResources().getColor(R.color.red));

如果使用还是有什么问题可以在主页中加我QQ,可以协助你解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants