Java Code Examples for android.widget.LinearLayout.setWeightSum()

The following are Jave code examples for showing how to use setWeightSum() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: TestChat   File: BaseDialog.java   View Source Code Vote up 5 votes
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;
}
 
Example 2
Project: TestChat   File: BaseDialog.java   View Source Code Vote up 5 votes
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;
}
 
Example 3
Project: phonk   File: PRow.java   View Source Code Vote up 5 votes
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);
}
 
Example 4
Project: MultipleS   File: MultipleSelector.java   View Source Code Vote up 4 votes
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);


}
 
Example 5
Project: MultipleS   File: MultipleSelector.java   View Source Code Vote up 4 votes
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);
}