jjzjj

getMeasuredHeight

全部标签

android - getMeasuredHeight() 和宽度在 measure() 之后返回 0

我真的对android为布局所做的整个测量事情感到困惑。基本上,我想在布局之前获取View的实际计算高度和宽度。我需要获得计算出的高度和宽度,因为我有一个隐藏的LinearLayout,我想在使用viewpropertyanimator打开时对其进行动画处理。我需要在动画制作之前将目标宽度(即计算出的宽度)提供给动画师。此布局的宽度是动态的,因为它依赖于其宽度的android:weight参数,因此我无法给出静态值。这是我的Activity课:packagecom.example.testproject;importandroid.app.Activity;importandroid.

android - 带有包装文本的 TextView 的 getMeasuredHeight()

我正在尝试确定TextView在绘制之前的高度。我正在使用以下代码来做到这一点:TextViewtextView=(TextView)findViewById(R.id.textview);textView.setText("TEST");intwidthSpec=MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT,MeasureSpec.EXACTLY);intheightSpec=MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED);textView.measure(wi

android - 带有包装文本的 TextView 的 getMeasuredHeight()

我正在尝试确定TextView在绘制之前的高度。我正在使用以下代码来做到这一点:TextViewtextView=(TextView)findViewById(R.id.textview);textView.setText("TEST");intwidthSpec=MeasureSpec.makeMeasureSpec(LayoutParams.MATCH_PARENT,MeasureSpec.EXACTLY);intheightSpec=MeasureSpec.makeMeasureSpec(0,MeasureSpec.UNSPECIFIED);textView.measure(wi

android - ViewGroup{TextView,...}.getMeasuredHeight 给出的错误值小于实际高度

{January14,2011...IhavegivenuptousesetListViewHeightBasedOnChildren(ListViewlistView},instead,Idon'tputmylistviewinascrollview,andthenjustputothercontentsintoalistviewbyusingListView.addHeaderView()andListView.addFooterView().http://dewr.egloos.com/5467045}ViewGroup(ViewGroup包含具有除换行符以外的长文本的TextV

android - getheight() 和 getmeasuredheight() 的区别

我正在经历这个http://developer.android.com/guide/topics/ui/declaring-layout.html当我看到一条线表明高度可以但不一定与测量高度不同时,我在想测量高度如何与布局高度不同。 最佳答案 方法View#getMeasuredWidth()和View#getMeasuredHeight()表示View想要的尺寸,在布局中的所有View被计算和放置之前屏幕。在View#onMeasure(int,int)和View#onLayout(boolean,int,int,int,int)

android - getmeasuredheight() 和 getmeasuredwidth() 在 View.measure() 之后返回 0

在使用view.measure()测量具有恒定尺寸的View之后,getMeasuredHeight()getMeasureWidth()返回0。layout_view.xml,扩展以创建View的布局测量尺寸的函数publicvoidmeasureView(Contextcontext){LayoutInflaterinflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);Viewview=inflater.inflate(R.layout.layout_view,null,f

Android getMeasuredHeight 返回错误值!

我正在尝试确定某些UI元素的实际尺寸(以像素为单位)!这些元素是从.xml文件中扩展而来的,并使用倾斜宽度和高度进行初始化,以便GUI最终支持多种屏幕尺寸和dpi(asrecommendedbyandroidspecs)。这个前面的xml代表一帧。但我确实在此处描述的水平布局中动态添加了许多:定义为在我的java代码中添加一帧的方法:privatevoidaddNewFrame(){LayoutInflaterinflater=(LayoutInflater)_parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SE

android - getMeasuredHeight 和 getHeight 有什么区别

我尝试在onGlobalLayout中调用View.getMeasuredHeight和View.getHeight。两者都给了我相同的结果。我想知道,在什么情况下它们的值会有所不同?有没有例子可以证明这一点?我尝试在谷歌中搜索。第一个结果似乎与这个问题无关:Android:HowtogetacustomView'sheightandwidth? 最佳答案 当您使用View时,它会对其子元素施加一定的大小限制。这些限制可能会阻止子元素占用它想要的空间量。documentationfortheViewclass对这些属性的描述如下:T