我有一个观点TableLayout, TableRow and TextView.我希望它看起来像一个网格.我需要得到这个网格的高度和宽度.这些方法getHeight()和getWidth()总是返回0.这发生在我和动态也格式化网格时我使用XML版本.
如何检索视图的尺寸?
这是我在Debug中用来检查结果的测试程序:
import android.app.Activity;
import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TextView;
public class appwig extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maindemo); //<- includes the grid called "board"
int vh = 0;
int vw = 0;
//Test-1 used the xml layout (which is displayed on the screen):
TableLayout tl = (TableLayout) findViewById(R.id.board);
tl = (TableLayout) findViewById(R.id.board);
vh = tl.getHeight(); //<- getHeight returned 0, Why?
vw = tl.getWidth(); //<- …Run Code Online (Sandbox Code Playgroud) 我想检测用户何时下拉以进行刷新
(ActionBar下的刷新行开始扩展到其UI宽度).
我想用消息替换ActionBar("向下滑动到刷新"),但是,
我不知道应该用哪个事件来调用我的函数.
我正在使用SwipeRefreshLayoutfrom,appcompact rev22但我想知道是否有一种方法可以更改区域长度,我可以将其下拉以显示刷新指示器,我不希望它在整个屏幕高度上工作,这可以做到吗?谢谢。