本文整理匯總了Java中android.widget.LinearLayout.MarginLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java LinearLayout.MarginLayoutParams方法的具體用法?Java LinearLayout.MarginLayoutParams怎麽用?Java LinearLayout.MarginLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.MarginLayoutParams方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addIndicator
import android.widget.LinearLayout; //導入方法依賴的package包/類
/**
* 添加底部Indicator點
*/
private void addIndicator() {
llIndicator.removeAllViews();
indicatorViews.clear();
for (int i = 0; i < carouselPageAdapter.getCount(); i++) {
View indicatorView = new View(context);
indicatorView.setBackgroundResource(i == 0 ? indicatorSelected : indicatorUnselected);
llIndicator.addView(indicatorView);
LinearLayout.MarginLayoutParams params = (LinearLayout.MarginLayoutParams) indicatorView.getLayoutParams();
if (i == 0 && indicatorSelectedWidth > 0 && indicatorSelectedHeight > 0) {
params.width = indicatorSelectedWidth;
params.height = indicatorSelectedHeight;
} else if (i > 0 && indicatorUnSelectedWidth > 0 && indicatorUnSelectedHeight > 0) {
params.width = indicatorUnSelectedWidth;
params.height = indicatorUnSelectedHeight;
} else {
params.width = indicatorWidth;
params.height = indicatorHeight;
}
params.leftMargin = indicatorPadding / 2;
params.rightMargin = indicatorPadding / 2;
indicatorView.setLayoutParams(params);
indicatorViews.add(indicatorView);
}
}