[英]How to align ImageView to the right side of the LinearLayout Programmatically android
[英]How to programmatically make a LinearLayout placed in the right side of the screen?
我有一個通過程序生成的圖像和文本視圖,但是我遇到了以下問題,如何使LinearLayout
邊距成為父級
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.