use of android.widget.LinearLayout.LayoutParams in project mobile-android by photo.
the class ImageFlowUtils method getSingleImageView.
protected View getSingleImageView(View convertView, T value, int imageHeight, int extraWidth, int layoutId, int imageViewId, Context context) {
View view;
ViewHolder viewHolder;
if (convertView == null) {
// if it's not recycled, instantiate and
// initialize
CommonUtils.debug(TAG, "Creating new view for child");
final LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = layoutInflater.inflate(layoutId, null);
viewHolder = creatViewHolder(view);
viewHolder.mImageView = (ImageView) view.findViewById(imageViewId);
view.setTag(viewHolder);
} else {
// Otherwise re-use the converted view
view = convertView;
viewHolder = (ViewHolder) view.getTag();
}
float ratio = getRatio(value);
int height = imageHeight;
int width = (int) (ratio * height) + extraWidth;
CommonUtils.debug(TAG, "getSingleImageView: processing image: " + value + "; Width: " + getWidth(value) + "; Height: " + getHeight(value) + "; Extra width: " + extraWidth + "; Req Width: " + width + "; Req Height: " + height);
width = width + 2 * borderSize;
height = height + 2 * borderSize;
LinearLayout.LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
if (layoutParams == null || layoutParams.width != width || layoutParams.height != height) {
layoutParams = new LinearLayout.LayoutParams(width, height);
view.setLayoutParams(layoutParams);
}
additionalSingleImageViewInit(view, value);
ImageView imageView = viewHolder.mImageView;
// Finally load the image asynchronously into the ImageView, this
// also takes care of
// setting a placeholder image while the background thread runs
loadImage(value, imageView);
return view;
}
use of android.widget.LinearLayout.LayoutParams in project VideoRecorder by qdrzwd.
the class Util method showDialog.
/**
* 公共弹窗
*
* @param context
* :Context 传入当前调用该方法的activity实例
* @param msg
* :String 要显示的显示文字
* @param type
* :int 显示类型1:仅为确定,2:有“确定”、“取消”两个操作
* @param handler
* :Handler 传入的需要回调的handler信息,可作为回调方法是用,msg.what = 1时为操作完成状态符
*/
public static void showDialog(Context context, String title, String content, int type, final Handler handler) {
final Dialog dialog = new Dialog(context, R.style.Dialog_loading);
dialog.setCancelable(true);
// 设置像是内容模板
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.global_dialog_tpl, null);
Button confirmButton = (Button) view.findViewById(// 确认
R.id.setting_account_bind_confirm);
Button cancelButton = (Button) view.findViewById(// 取消
R.id.setting_account_bind_cancel);
TextView dialogTitle = (TextView) view.findViewById(// 标题
R.id.global_dialog_title);
// 中竖线
View lineHoriCenter = view.findViewById(R.id.line_hori_center);
// 默认隐藏取消按钮
confirmButton.setVisibility(View.GONE);
lineHoriCenter.setVisibility(View.GONE);
TextView textView = (TextView) view.findViewById(R.id.setting_account_bind_text);
// 设置对话框的宽度
Window dialogWindow = dialog.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = (int) (context.getResources().getDisplayMetrics().density * 288);
dialogWindow.setAttributes(lp);
// 设置显示类型
if (type != 1 && type != 2) {
type = 1;
}
// 设置标题
dialogTitle.setText(title);
// 设置提示内容
textView.setText(content);
// 确认按钮操作
if (type == 1 || type == 2) {
confirmButton.setVisibility(View.VISIBLE);
confirmButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (handler != null) {
Message msg = handler.obtainMessage();
msg.what = 1;
handler.sendMessage(msg);
}
dialog.dismiss();
}
});
}
// 取消按钮事件
if (type == 2) {
cancelButton.setVisibility(View.VISIBLE);
lineHoriCenter.setVisibility(View.VISIBLE);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (handler != null) {
Message msg = handler.obtainMessage();
msg.what = 0;
handler.sendMessage(msg);
}
dialog.dismiss();
}
});
}
dialog.addContentView(view, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
// 点击返回键关闭
dialog.setCancelable(true);
// 点击外部关闭
dialog.setCanceledOnTouchOutside(true);
dialog.show();
}
use of android.widget.LinearLayout.LayoutParams in project platform_frameworks_base by android.
the class GlyphCacheActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView scrollView = new ScrollView(this);
scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
scrollView.addView(layout);
while (mTotalChars < 10000) {
layout.addView(createTextView());
}
setContentView(scrollView);
}
use of android.widget.LinearLayout.LayoutParams in project platform_frameworks_base by android.
the class SurfaceAndTextureViews method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.surface_texture_views);
final ViewGroup container = (ViewGroup) findViewById(R.id.container);
Button toggleButton = (Button) findViewById(R.id.toggleButton);
mView = new SimpleView(this);
mView.setId(0);
mView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mView);
mSurfaceView = new SimpleSurfaceView(this);
mSurfaceView.setId(1);
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mSurfaceView);
mTextureView = new SimpleTextureView(this);
mTextureView.setId(2);
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
container.addView(mTextureView);
final TransitionSet transition = new TransitionSet();
transition.addTransition(new ChangeBounds()).addTransition(new Crossfade().addTarget(0).addTarget(1).addTarget(2));
toggleButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Scene newScene = new Scene(container);
newScene.setEnterAction(new Runnable() {
@Override
public void run() {
if (mView.getWidth() <= SMALL_SIZE) {
mView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE * 2, SMALL_SIZE));
mView.mColor = SimpleView.LARGE_COLOR;
mSurfaceView.mColor = SimpleSurfaceView.LARGE_COLOR;
mTextureView.mColor = SimpleTextureView.LARGE_COLOR;
} else {
mView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mSurfaceView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mTextureView.setLayoutParams(new LayoutParams(SMALL_SIZE, SMALL_SIZE));
mView.mColor = SimpleView.SMALL_COLOR;
mSurfaceView.mColor = SimpleSurfaceView.SMALL_COLOR;
mTextureView.mColor = SimpleTextureView.SMALL_COLOR;
}
}
});
TransitionManager.go(newScene, transition);
}
});
}
use of android.widget.LinearLayout.LayoutParams in project platform_frameworks_base by android.
the class CrossfadeMultiple method sendMessage.
public void sendMessage(View view) {
TransitionManager.beginDelayedTransition(mSceneRoot, mTransition);
int id = view.getId();
LayoutParams params = null;
switch(id) {
case R.id.button1:
params = new LayoutParams(200, 200);
mButton.setText("A");
mTextView.setText("1111111");
mImageView.setImageResource(R.drawable.self_portrait_square_100);
break;
case R.id.button2:
params = new LayoutParams(400, 200);
mButton.setText("B");
mTextView.setText("2222222");
mImageView.setImageResource(R.drawable.self_portrait_square_200);
break;
case R.id.button3:
params = new LayoutParams(200, 400);
mButton.setText("C");
mTextView.setText("3333333");
mImageView.setImageResource(R.drawable.self_portrait_square_400);
break;
}
mButton.setLayoutParams(params);
}
Aggregations