use of android.widget.LinearLayout.LayoutParams in project nmid-headline by miao1007.
the class EditPage method getMainBody.
private LinearLayout getMainBody() {
LinearLayout llMainBody = new LinearLayout(getContext());
llMainBody.setOrientation(LinearLayout.VERTICAL);
LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpMain.weight = 1;
int dp_4 = dipToPx(getContext(), 4);
lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
llMainBody.setLayoutParams(lpMain);
LinearLayout llContent = new LinearLayout(getContext());
LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lpContent.weight = 1;
llMainBody.addView(llContent, lpContent);
// share content editor
etContent = new EditText(getContext());
etContent.setGravity(Gravity.LEFT | Gravity.TOP);
etContent.setBackgroundDrawable(null);
etContent.setText(String.valueOf(shareParamMap.get("text")));
etContent.addTextChangedListener(this);
LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lpEt.weight = 1;
etContent.setLayoutParams(lpEt);
llContent.addView(etContent);
llContent.addView(getThumbView());
llMainBody.addView(getBodyBottom());
return llMainBody;
}
use of android.widget.LinearLayout.LayoutParams in project nmid-headline by miao1007.
the class EditPage method getSep.
private View getSep() {
View vSep = new View(getContext());
vSep.setBackgroundColor(0xff000000);
int dp_1 = dipToPx(getContext(), 1);
LayoutParams lpSep = new LayoutParams(LayoutParams.MATCH_PARENT, dp_1);
vSep.setLayoutParams(lpSep);
return vSep;
}
use of android.widget.LinearLayout.LayoutParams in project nmid-headline by miao1007.
the class EditPage method getThumbView.
// shared image container
private RelativeLayout getThumbView() {
rlThumb = new RelativeLayout(getContext());
rlThumb.setId(1);
int dp_82 = dipToPx(getContext(), 82);
int dp_98 = dipToPx(getContext(), 98);
LayoutParams lpThumb = new LayoutParams(dp_82, dp_98);
rlThumb.setLayoutParams(lpThumb);
ivImage = new ImageView(getContext());
int resId = getBitmapRes(activity, "btn_back_nor");
if (resId > 0) {
ivImage.setBackgroundResource(resId);
}
ivImage.setScaleType(ScaleType.CENTER_INSIDE);
ivImage.setImageBitmap(image);
int dp_4 = dipToPx(getContext(), 4);
ivImage.setPadding(dp_4, dp_4, dp_4, dp_4);
int dp_74 = dipToPx(getContext(), 74);
RelativeLayout.LayoutParams lpImage = new RelativeLayout.LayoutParams(dp_74, dp_74);
int dp_16 = dipToPx(getContext(), 16);
int dp_8 = dipToPx(getContext(), 8);
lpImage.setMargins(0, dp_16, dp_8, 0);
ivImage.setLayoutParams(lpImage);
ivImage.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (image != null && !image.isRecycled()) {
PicViewer pv = new PicViewer();
pv.setImageBitmap(image);
pv.show(activity, null);
}
}
});
rlThumb.addView(ivImage);
int dp_24 = dipToPx(getContext(), 24);
progressBar = new ProgressBar(getContext());
progressBar.setPadding(dp_24, dp_24, dp_24, dp_24);
RelativeLayout.LayoutParams pb = new RelativeLayout.LayoutParams(dp_74, dp_74);
pb.setMargins(0, dp_16, dp_8, 0);
progressBar.setLayoutParams(pb);
rlThumb.addView(progressBar);
Button btn = new Button(getContext());
btn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// remove the photo to share
rlThumb.setVisibility(View.GONE);
ivPin.setVisibility(View.GONE);
removeImage(imgInfo);
}
});
resId = getBitmapRes(activity, "img_cancel");
if (resId > 0) {
btn.setBackgroundResource(resId);
}
int dp_20 = dipToPx(getContext(), 20);
RelativeLayout.LayoutParams lpBtn = new RelativeLayout.LayoutParams(dp_20, dp_20);
lpBtn.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
lpBtn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
btn.setLayoutParams(lpBtn);
rlThumb.addView(btn);
if (!haveImage()) {
rlThumb.setVisibility(View.GONE);
}
return rlThumb;
}
use of android.widget.LinearLayout.LayoutParams in project nmid-headline by miao1007.
the class EditPage method afterPlatformListGot.
/** display platform list */
public void afterPlatformListGot() {
int size = platformList == null ? 0 : platformList.length;
views = new View[size];
final int dp_24 = dipToPx(getContext(), 24);
LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
final int dp_9 = dipToPx(getContext(), 9);
lpItem.setMargins(0, 0, dp_9, 0);
FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lpMask.gravity = Gravity.LEFT | Gravity.TOP;
int selection = 0;
for (int i = 0; i < size; i++) {
FrameLayout fl = new FrameLayout(getContext());
fl.setLayoutParams(lpItem);
if (i >= size - 1) {
fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
}
llPlat.addView(fl);
fl.setOnClickListener(this);
ImageView iv = new ImageView(getContext());
iv.setScaleType(ScaleType.CENTER_INSIDE);
iv.setImageBitmap(getPlatLogo(platformList[i]));
iv.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
fl.addView(iv);
views[i] = new View(getContext());
views[i].setBackgroundColor(0xcfffffff);
views[i].setOnClickListener(this);
String platformName = platformList[i].getName();
for (Platform plat : platforms) {
if (platformName.equals(plat.getName())) {
views[i].setVisibility(View.INVISIBLE);
selection = i;
}
}
views[i].setLayoutParams(lpMask);
fl.addView(views[i]);
}
final int postSel = selection;
UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
public boolean handleMessage(Message msg) {
HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent();
hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
return false;
}
});
}
use of android.widget.LinearLayout.LayoutParams in project gesture-imageview by jasonpolites.
the class DoubleImage method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.double_image);
LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
view = new GestureImageView(this);
view.setLayoutParams(params);
ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
layout.addView(view);
handler.sendEmptyMessageDelayed(IMAGE_LOAD, 2000);
}
Aggregations