package org.itsnat.droid.impl.xmlinflater.layout.attr.view; import android.view.View; import android.view.ViewGroup; import org.itsnat.droid.impl.dom.DOMAttr; import org.itsnat.droid.impl.xmlinflater.layout.AttrLayoutContext; import org.itsnat.droid.impl.xmlinflater.layout.PendingViewPostCreateProcess; import org.itsnat.droid.impl.xmlinflater.layout.classtree.ClassDescViewBased; import org.itsnat.droid.impl.xmlinflater.shared.attr.AttrDesc; /** * Created by jmarranz on 30/04/14. */ public class AttrDescView_view_View_layout_height extends AttrDesc<ClassDescViewBased,View,AttrLayoutContext> { public AttrDescView_view_View_layout_height(ClassDescViewBased parent) { super(parent,"layout_height"); } @Override public void setAttribute(final View view, DOMAttr attr, AttrLayoutContext attrCtx) { final int height = getDimensionWithNameIntRound(attr.getResourceDesc(), attrCtx.getXMLInflaterContext()); Runnable task = new Runnable(){ @Override public void run() { ViewGroup.LayoutParams params = view.getLayoutParams(); params.height = height; }}; PendingViewPostCreateProcess pendingViewPostCreateProcess = attrCtx.getPendingViewPostCreateProcess(); if (pendingViewPostCreateProcess != null) { pendingViewPostCreateProcess.addPendingLayoutParamsTask(task); } else { task.run(); PendingViewPostCreateProcess.onChangedLayoutParams(view); } } @Override public void removeAttribute(View view, AttrLayoutContext attrCtx) { ViewGroup.LayoutParams params = view.getLayoutParams(); params.height = ViewGroup.LayoutParams.MATCH_PARENT; // Por poner algo, no lo tengo claro y yo creo que puede cambiar segĂșn el ViewGroup padre PendingViewPostCreateProcess.onChangedLayoutParams(view); } }