以下是我有:如何以编程方式将TextView和EditText对齐到水平LinearLayout?
LinearLayout horizontalLL = new LinearLayout(thisActivity);
horizontalLL.setOrientation(LinearLayout.HORIZONTAL);
horizontalLL.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.MATCH_PARENT, LinearLayoutCompat.LayoutParams.WRAP_CONTENT,1));
TextView captionTV = new TextView(thisActivity);
captionTV.setText(element.description);
captionTV.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT, LinearLayoutCompat.LayoutParams.WRAP_CONTENT));
editText.setLayoutParams(new LinearLayoutCompat.LayoutParams(LinearLayoutCompat.LayoutParams.WRAP_CONTENT, LinearLayoutCompat.LayoutParams.WRAP_CONTENT,0.6f));
horizontalLL.addView(captionTV);
horizontalLL.addView(editText);
LL.addView(horizontalLL);
,但效果不好:该EDITTEXT还很短,不填充水平线性布局。我试图设置captionTV的重量,但仍然没有结果。
你试过用MATCH_PARENT替代WRAP_CONTENT为edittext? –
要清楚你的问题,你想编辑文字大小增加或什么,如果它的情况下尝试MATCH_PARENT或给一些手动编号240dp –