/** * 设置左右比例 * * @param left 左边占权重 * @param right 右边占权重 */ public void setScale(int left, int right) { setWeightSum(left + right); LayoutParams leftParams = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, left); mListView1.setLayoutParams(leftParams); LayoutParams rightParams = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, right); mListView2.setLayoutParams(rightParams); }
private void init(Context context) { setOrientation(HORIZONTAL); setWeightSum(2); mListView1 = new FixedHeightListView(context); mListView2 = new FixedHeightListView(context); mListView1.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mListView2.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); mListView2.setDivider(null); LayoutParams params = new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1); mListView1.setLayoutParams(params); mListView2.setLayoutParams(params); mListView1.setVerticalScrollBarEnabled(false); mListView2.setVerticalScrollBarEnabled(false); addView(mListView1); addView(mListView2); }