使用LinearLayout动态生成具有权重的TextView
LinearLayout lin_hoizontal = new LinearLayout(context)
lin_hoizontal.setOrientation(LinearLayout.HORIZONTAL)
lin_hoizontal.setLayoutParams(new android.widget.LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 10f))
lin_hoizontal.setPadding((int) context.getResources().getDimension(R.dimen.d_8), (int) context.getResources().getDimension(R.dimen.d_2), (int) context.getResources().getDimension(R.dimen.d_8), (int) context.getResources().getDimension(R.dimen.d_2))
android.widget.LinearLayout.LayoutParams params_label = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 2.5f)
TextView txt_label = new TextView(context)
txt_label.setTextColor(context.getResources().getColor(R.color.listing_header_txt_color))
txt_label.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.d_13))
txt_label.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL))
txt_label.setLayoutParams(params_label)
txt_label.setPadding(0, 0, (int) context.getResources().getDimension(R.dimen.d_2), 0)
txt_label.setText("Label")
android.widget.LinearLayout.LayoutParams params_value = new android.widget.LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 7.5f)
TextView txt_value = new TextView(context)
txt_value.setTextColor(context.getResources().getColor(R.color.listing_header_txt_color))
txt_value.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources().getDimension(R.dimen.d_13))
txt_value.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL))
txt_value.setLayoutParams(params_value)
txt_value.setPadding((int) context.getResources().getDimension(R.dimen.d_2), 0, 0, 0)
txt_value.setText("Value")
lin_hoizontal.addView(txt_label)
lin_hoizontal.addView(txt_value)
lin_hoizontal.addView(lin_main)