use of android.widget.LinearLayout.LayoutParams in project android-app by eoecn.
the class UserCollectFragment method CreateTextView.
private TextView CreateTextView(final int i, String name) {
// TODO Auto-generated method stub
TextView tv = new TextView(mContext);
int width = wm.getDefaultDisplay().getWidth() / 3;
LayoutParams layout = new LayoutParams(width, LayoutParams.MATCH_PARENT);
tv.setLayoutParams(layout);
if (i == 0) {
tv.setBackgroundResource(R.drawable.dis_usercollect_left);
mLinearLayout.setTag(tv);
}
tv.setGravity(Gravity.CENTER);
tv.setTextColor(Color.BLACK);
tv.setText(name);
tv.setClickable(true);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mUserFragment.setListContent(mUserResponse.getFavorite().get(i));
if (mLinearLayout.getTag() != null) {
((View) mLinearLayout.getTag()).setBackgroundColor(Color.TRANSPARENT);
}
mLinearLayout.setTag(v);
if (i == 0) {
v.setBackgroundResource(R.drawable.dis_usercollect_left);
} else if (i == mUserResponse.getFavorite().size() - 1) {
v.setBackgroundResource(R.drawable.dis_usercollect_right);
}
}
});
return tv;
}
use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.
the class PowerTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
LinearLayout contentView = new LinearLayout(this);
contentView.setOrientation(LinearLayout.VERTICAL);
setContentView(contentView);
setTitle("Idle");
webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
webViewClient = new SimpleWebViewClient();
chromeClient = new SimpleChromeClient();
webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(chromeClient);
contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case MSG_TIMEOUT:
handleTimeout();
return;
case MSG_NAVIGATE:
manualDelay = msg.arg2;
navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
return;
}
}
};
pageDoneLock = new Object();
}
use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.
the class ReliabilityTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v(LOGTAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
LinearLayout contentView = new LinearLayout(this);
contentView.setOrientation(LinearLayout.VERTICAL);
setContentView(contentView);
setTitle("Idle");
webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
webViewClient = new SimpleWebViewClient();
chromeClient = new SimpleChromeClient();
webView.setWebViewClient(webViewClient);
webView.setWebChromeClient(chromeClient);
contentView.addView(webView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0f));
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch(msg.what) {
case MSG_TIMEOUT:
handleTimeout();
return;
case MSG_NAVIGATE:
manualDelay = msg.arg2;
navigate(msg.getData().getString(MSG_NAV_URL), msg.arg1);
logTime = msg.getData().getBoolean(MSG_NAV_LOGTIME);
return;
}
}
};
pageDoneLock = new Object();
}
use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by ParanoidAndroid.
the class LinearLayoutTest method create.
public ViewGroup create(Context context) {
LinearLayout container = new LinearLayout(context);
container.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < VERTICAL_ALIGNMENTS.length; i++) {
int va = VERTICAL_ALIGNMENTS[i];
for (int j = 0; j < HORIZONTAL_ALIGNMENTS.length; j++) {
int ha = HORIZONTAL_ALIGNMENTS[j];
LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
lp.gravity = va | ha;
View v = create(context, VERTICAL_NAMES[i] + "-" + HORIZONTAL_NAMES[j], 20);
container.addView(v, lp);
}
}
return container;
}
use of android.widget.LinearLayout.LayoutParams in project Anki-Android by Ramblurr.
the class BasicImageFieldController method createUI.
@Override
public void createUI(LinearLayout layout) {
mImagePreview = new ImageView(mActivity);
DisplayMetrics metrics = getDisplayMetrics();
int height = metrics.heightPixels;
int width = metrics.widthPixels;
LinearLayout.LayoutParams p = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
setPreviewImage(mField.getImagePath(), getMaxImageSize());
mImagePreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mImagePreview.setAdjustViewBounds(true);
mImagePreview.setMaxHeight((int) Math.round(height * 0.4));
mImagePreview.setMaxWidth((int) Math.round(width * 0.6));
mBtnGallery = new Button(mActivity);
mBtnGallery.setText(gtxt(R.string.multimedia_editor_image_field_editing_galery));
mBtnGallery.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
mActivity.startActivityForResult(i, ACTIVITY_SELECT_IMAGE);
}
});
mBtnCamera = new Button(mActivity);
mBtnCamera.setText(gtxt(R.string.multimedia_editor_image_field_editing_photo));
mBtnCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
File image;
try {
image = File.createTempFile("ankidroid_img", ".jpg");
mTempCameraImagePath = image.getPath();
Uri uriSavedImage = Uri.fromFile(image);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
mActivity.startActivityForResult(cameraIntent, ACTIVITY_TAKE_PICTURE);
} catch (IOException e) {
e.printStackTrace();
}
}
});
layout.addView(mImagePreview, LinearLayout.LayoutParams.FILL_PARENT, p);
layout.addView(mBtnGallery, LinearLayout.LayoutParams.FILL_PARENT);
layout.addView(mBtnCamera, LinearLayout.LayoutParams.FILL_PARENT);
}
Aggregations