當前位置: 首頁>>代碼示例>>Java>>正文


Java LinearLayout.setWeightSum方法代碼示例

本文整理匯總了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;
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:29,代碼來源:BaseDialog.java

示例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);
}
 
開發者ID:victordiaz,項目名稱:phonk,代碼行數:13,代碼來源:PRow.java

示例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);


}
 
開發者ID:yeshuwei,項目名稱:MultipleS,代碼行數:45,代碼來源:MultipleSelector.java

示例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);
}
 
開發者ID:yeshuwei,項目名稱:MultipleS,代碼行數:43,代碼來源:MultipleSelector.java


注:本文中的android.widget.LinearLayout.setWeightSum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。