如何以编程方式将 LinearLayout 放置在屏幕的右侧?
How to programmatically make a LinearLayout placed in the right side of the screen?
我有一个以编程方式生成的图像和文本视图,但我遇到了如何使 LinearLayout
margin parent 正确的问题
这是我的代码
LinearLayout lin = (LinearLayout) convertView.findViewById(R.id.linearChat);
final ImageView img1 = new ImageView(context);
final TextView tv1 = new TextView(context);
tv1.setText(chat.getPesan());
img1.setImageDrawable(context.getResources().getDrawable(R.drawable.cservice));
lin.addView(tv1);
tv1.setBackgroundResource(R.drawable.rounded_corner1);
tv1.setPadding(10,10,10,10);
lin.addView(img1);
添加setMargin()
行,
// Left Top Right Bottom Margin
tv1.setMargins(25,25,25,25); // adjust according to your need
我有一个以编程方式生成的图像和文本视图,但我遇到了如何使 LinearLayout
margin parent 正确的问题
这是我的代码
LinearLayout lin = (LinearLayout) convertView.findViewById(R.id.linearChat);
final ImageView img1 = new ImageView(context);
final TextView tv1 = new TextView(context);
tv1.setText(chat.getPesan());
img1.setImageDrawable(context.getResources().getDrawable(R.drawable.cservice));
lin.addView(tv1);
tv1.setBackgroundResource(R.drawable.rounded_corner1);
tv1.setPadding(10,10,10,10);
lin.addView(img1);
添加setMargin()
行,
// Left Top Right Bottom Margin
tv1.setMargins(25,25,25,25); // adjust according to your need