我想重力設置爲我設計的權利,但它並沒有正常工作: (下面的代碼是一個循環內)組佈局重心向右
LinearLayout lin = new LinearLayout(getActivity());
LayoutParams lin_parms = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
lin_parms.gravity = Gravity.RIGHT;
lin.setLayoutParams(lin_parms);
lin.setGravity(Gravity.RIGHT);
LayoutParams txt_parms = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
txt_parms.gravity = Gravity.RIGHT;
TextView txt_view = new TextView(getActivity());
txt_view.setLayoutParams(txt_parms);
txt_view.setTypeface(font);
txt_view.setText("hello");
lin.addView(txt_view);
lay_lin_list_tractions.addView(lin);
你試過設置layout_gravity =「right」? – Umair 2014-10-31 11:09:20
不清楚你期望什麼。請解釋預期結果 – 2014-10-31 11:09:48