0
根據我的要求,我應該只給出水平方向,如果我在3個文本視圖中給出3個句子,如果沒有第三個句子的空間,那麼它應該進入下一行第一位置...Android - JAVA文件中的佈局
公共類MainActivity擴展活動{
private LinearLayout layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
findViewById();
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(10, 15, 10, 10);
layout.setOrientation(LinearLayout.HORIZONTAL);
android.view.ViewGroup.LayoutParams params;
TextView tvTextsecond = new TextView(this);
tvTextsecond.setText("Heywhatrudoingtoday");
tvTextsecond.setLayoutParams(layoutParams);
tvTextsecond.setBackgroundColor(Color.RED);
tvTextsecond.setTextColor(Color.WHITE);
TextView tvTextthird = new TextView(this);
tvTextthird.setText("Haiitssundaytowork");
tvTextthird.setLayoutParams(layoutParams);
tvTextthird.setBackgroundColor(Color.BLUE);
tvTextthird.setTextColor(Color.WHITE);
TextView tvTextfourth = new TextView(this);
tvTextfourth.setText("Owebullshitruuselessfellow");
tvTextfourth.setLayoutParams(layoutParams);
tvTextfourth.setBackgroundColor(Color.YELLOW);
tvTextfourth.setTextColor(Color.WHITE);
layout.addView(tvTextsecond);
layout.addView(tvTextthird);
layout.addView(tvTextfourth);
}
private void findViewById() {
layout = (LinearLayout) findViewById(R.id.flowLayout);
}
}
不正是LinearLayout在告訴它包裝其內容時做的事情嗎? – 2013-04-04 10:03:01
我不能理解你的問題蒂莫西。 我需要做線性佈局的所有包裝佈局屬性。 例如:如果我在3個文本視圖中給出3個句子,如果沒有第三個句子的空間,那麼它應該在第一個位置進入下一行...... – user2109950 2013-04-04 10:26:58
除了線性佈局如何解決這個查詢,請給我是完美的解決方案... – user2109950 2013-04-04 10:37:44