我想以编程方式将代码中的进度条居中。这里是我的代码:如何以编程方式在布局中居中进度条?
LinearLayout streamLayout = new LinearLayout(this);
streamLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
streamLayout.setOrientation(LinearLayout.VERTICAL);
streamLayout.setGravity(Gravity.CENTER);
LinearLayout newsLayout = new LinearLayout(this);
streamLayout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
streamLayout.setOrientation(LinearLayout.VERTICAL);
streamLayout.setGravity(Gravity.CENTER);
mSwipeView.addView(streamLayout);
mSwipeView.addView(newsLayout);
mSwipeView.addView(new LinearLayout(this));
((LinearLayout) mSwipeView.getChildContainer().getChildAt(0)).addView(streamListView);
((LinearLayout) mSwipeView.getChildContainer().getChildAt(0)).addView(streamProgressBar);
((LinearLayout) mSwipeView.getChildContainer().getChildAt(1)).addView(newsListView);
((LinearLayout) mSwipeView.getChildContainer().getChildAt(1)).addView(newsProgressBar);
((LinearLayout) mSwipeView.getChildContainer().getChildAt(2)).addView(chartImageView);
我怎样才能让进度条在垂直居中,并在我的布局水平?
在什么中央?屏幕,布局? – ernazm 2011-05-18 13:18:59
我相信他是指布局中的水平中心。 – DArkO 2011-05-18 13:24:28
是的,我指的是布局 – 2011-05-18 13:40:44