imageview add xmlparser entry,fix tablayout's tabtextcolor caused crash

This commit is contained in:
侯歌 2022-01-21 14:33:27 +08:00
parent f43509b9e4
commit dafacdc740
4 changed files with 18 additions and 9 deletions

View File

@ -4,6 +4,8 @@
#include <cdlog.h>
namespace cdroid{
DECLARE_WIDGET(ImageView)
ImageView::ImageView(Context*ctx,const AttributeSet& attrs)
:View(ctx,attrs){
initImageView();

View File

@ -49,6 +49,11 @@ TabLayout::TabLayout(Context*context,const AttributeSet&atts)
applyModeAndGravity();
}
TabLayout::~TabLayout(){
delete mTabTextColors;
delete mScrollAnimator;
}
void TabLayout::initTabLayout(){
AttributeSet atts;
mMode = MODE_SCROLLABLE;
@ -905,8 +910,7 @@ void TabLayout::TabView::setSelected(bool selected) {
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
}*/
// Always dispatch this to the child views, regardless of whether the value has
// changed
// Always dispatch this to the child views, regardless of whether the value has changed
if (mTextView) mTextView->setSelected(selected);
if (mIconView) mIconView->setSelected(selected);
@ -1042,7 +1046,7 @@ void TabLayout::TabView::update() {
}
//TextViewCompat.setTextAppearance(mTextView, mTabTextAppearance);
if (mParent->mTabTextColors) {
mTextView->setTextColor(mParent->mTabTextColors);
mTextView->setTextColor(new ColorStateList(*mParent->mTabTextColors));
}
updateTextAndIcon(mTextView, mIconView);
} else {

View File

@ -232,6 +232,7 @@ protected:
public:
TabLayout(int w,int h);
TabLayout(Context*context,const AttributeSet&atts);
~TabLayout();
void setSelectedTabIndicatorColor( int color);
void setSelectedTabIndicatorHeight(int height);
void setScrollPosition(int position, float positionOffset, bool updateSelectedText);

View File

@ -220,9 +220,16 @@ public:
bool mHasLetterSpacing = false;
float mLetterSpacing = 0;
public:
TextAppearanceAttributes();
void readTextAppearance(Context*ctx,const AttributeSet&atts);
};
TextAppearanceAttributes::TextAppearanceAttributes(){
mTextColor = nullptr;
mTextColorHint= nullptr;
mTextColorLink= nullptr;
}
void TextAppearanceAttributes::readTextAppearance(Context*ctx,const AttributeSet&atts){
mTextColorHighlight = atts.getColor("textColorHighlight",mTextColorHighlight);
mTextColor = ctx->getColorStateList(atts.getString("textColor"));
@ -320,11 +327,6 @@ void TextView::initView(){
mEditMode =READONLY;
setTextColor(0xFFFFFFFF);
setHintTextColor(0xFFFFFFFF);
TextAppearanceAttributes attributes;
attributes.mTextColor = ColorStateList::valueOf(0xFFFFFFFF);
attributes.mTextSize = 18;
applyTextAppearance(&attributes);
}
TextView::~TextView() {
@ -1030,7 +1032,7 @@ void TextView::setTextColor(int color){
}
void TextView::setTextColor(ColorStateList* colors){
if(colors!=nullptr){
if((colors!=nullptr)&&(colors!=mTextColor)){
delete mTextColor;
mTextColor = colors;
updateTextColors();