本文整理汇总了Java中android.widget.LinearLayout.setWeightSum方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.setWeightSum方法的具体用法?Java LinearLayout.setWeightSum怎么用?Java LinearLayout.setWeightSum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.LinearLayout
的用法示例。
在下文中一共展示了LinearLayout.setWeightSum方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setCheckBoxName
import android.widget.LinearLayout; //导入方法依赖的package包/类
public BaseDialog setCheckBoxName(List<String> list) {
if (middleLayout.getChildCount() > 0) {
middleLayout.removeAllViews();
}
for (String title :
list) {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.START);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.weight = 1;
textView.setLayoutParams(layoutParams);
textView.setText(title);
final CheckBox checkBox = new CheckBox(getContext());
checkBox.setGravity(Gravity.END);
LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
checkBoxLayout.weight = 1;
checkBox.setLayoutParams(checkBoxLayout);
LinearLayout linearLayout = new LinearLayout(getContext());
LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
linearLayout.setGravity(Gravity.CENTER_VERTICAL);
linearLayout.setWeightSum(2);
linearLayout.setLayoutParams(linearLayoutParam);
linearLayout.addView(textView);
linearLayout.addView(checkBox);
middleLayout.addView(linearLayout);
}
return this;
}
示例2: PRow
import android.widget.LinearLayout; //导入方法依赖的package包/类
public PRow(Context c, LinearLayout cardLl, int n) {
this.n = n;
float t = 100f;
float tt = t / n;
ll = new LinearLayout(c);
ll.setOrientation(LinearLayout.HORIZONTAL);
ll.setWeightSum(t);
cardLl.addView(ll);
lParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, tt);
}
示例3: initHorizontalView
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initHorizontalView(Context context) {
removeAllViews();
setOrientation(VERTICAL);
tabGroup = new LinearLayout(context);
tabGroup.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
tabGroup.setWeightSum(tabCount);
tabGroup.setOrientation(HORIZONTAL);
addView(tabGroup);
TabView tab = addTab(tabTextHint, true);
tabGroup.addView(tab);
tabList = new ArrayList<>();
tabList.add(tab);
for (int i = 1; i < tabCount; i++) {
TabView nullTab = addTab("", false);
nullTab.setIndex(i);
tabGroup.addView(nullTab);
tabList.add(nullTab);
}
indicatorView = new IndicatorView(context, tabCount);
indicatorView.setBgColor(indicatorColor);
indicatorView.setTabOrientation(HORIZONTAL);
indicatorView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 6));
addView(indicatorView);
divisionLine = new View(context);
divisionLine.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, 2));
divisionLine.setBackgroundColor(context.getResources().getColor(R.color.gray_line));
addView(divisionLine);
recyclerView = new RecyclerView(context);
recyclerView.setLayoutManager(manager);
if (manager instanceof GridLayoutManager){
recyclerView.addItemDecoration(new SpaceItemDecoration(space));
}
LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layoutParams.setMargins(10,10,10,0);
recyclerView.setLayoutParams(layoutParams);
addView(recyclerView);
}
示例4: initVerticalView
import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initVerticalView(Context context) {
removeAllViews();
setOrientation(HORIZONTAL);
tabGroup = new LinearLayout(context);
tabGroup.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
tabGroup.setOrientation(VERTICAL);
tabGroup.setWeightSum(tabCount);
addView(tabGroup);
TabView tab = addTab(tabTextHint, true);
tabGroup.addView(tab);
tabList = new ArrayList<>();
tabList.add(tab);
for (int i = 1; i < tabCount; i++) {
TabView nullTab = addTab("", false);
tabList.add(nullTab);
tabGroup.addView(nullTab);
nullTab.setIndex(i);
}
indicatorView = new IndicatorView(context, tabCount);
indicatorView.setBgColor(indicatorColor);
indicatorView.setTabOrientation(VERTICAL);
indicatorView.setLayoutParams(new LayoutParams(6, ViewGroup.LayoutParams.MATCH_PARENT));
addView(indicatorView);
divisionLine = new View(context);
divisionLine.setLayoutParams(new LayoutParams(
2, LayoutParams.MATCH_PARENT));
divisionLine.setBackgroundColor(context.getResources().getColor(R.color.gray_line));
addView(divisionLine);
recyclerView = new RecyclerView(context);
recyclerView.setLayoutManager(manager);
if (manager instanceof GridLayoutManager){
recyclerView.addItemDecoration(new SpaceItemDecoration(space));
}
LayoutParams layoutParams=new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
layoutParams.setMargins(10,10,10,0);
recyclerView.setLayoutParams(layoutParams);
addView(recyclerView);
}