use of android.widget.LinearLayout in project platform_frameworks_base by android.
the class DpiTestActivity method addBitmapDrawable.
private void addBitmapDrawable(LinearLayout layout, int resource, boolean scale) {
Bitmap bitmap;
bitmap = loadAndPrintDpi(resource, scale);
View view = new View(this);
final BitmapDrawable d = new BitmapDrawable(getResources(), bitmap);
if (!scale)
d.setTargetDensity(getResources().getDisplayMetrics());
view.setBackgroundDrawable(d);
view.setLayoutParams(new LinearLayout.LayoutParams(d.getIntrinsicWidth(), d.getIntrinsicHeight()));
layout.addView(view);
}
use of android.widget.LinearLayout in project platform_frameworks_base by android.
the class DpiTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
this.setTitle(R.string.act_title);
LinearLayout root = new LinearLayout(this);
root.setOrientation(LinearLayout.VERTICAL);
LinearLayout layout = new LinearLayout(this);
addBitmapDrawable(layout, R.drawable.logo120dpi, true);
addBitmapDrawable(layout, R.drawable.logo160dpi, true);
addBitmapDrawable(layout, R.drawable.logo240dpi, true);
addLabelToRoot(root, "Prescaled bitmap in drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addBitmapDrawable(layout, R.drawable.logo120dpi, false);
addBitmapDrawable(layout, R.drawable.logo160dpi, false);
addBitmapDrawable(layout, R.drawable.logo240dpi, false);
addLabelToRoot(root, "Autoscaled bitmap in drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addResourceDrawable(layout, R.drawable.logo120dpi);
addResourceDrawable(layout, R.drawable.logo160dpi);
addResourceDrawable(layout, R.drawable.logo240dpi);
addLabelToRoot(root, "Prescaled resource drawable");
addChildToRoot(root, layout);
layout = (LinearLayout) li.inflate(R.layout.image_views, null);
addLabelToRoot(root, "Inflated layout");
addChildToRoot(root, layout);
layout = (LinearLayout) li.inflate(R.layout.styled_image_views, null);
addLabelToRoot(root, "Inflated styled layout");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addCanvasBitmap(layout, R.drawable.logo120dpi, true);
addCanvasBitmap(layout, R.drawable.logo160dpi, true);
addCanvasBitmap(layout, R.drawable.logo240dpi, true);
addLabelToRoot(root, "Prescaled bitmap");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addCanvasBitmap(layout, R.drawable.logo120dpi, false);
addCanvasBitmap(layout, R.drawable.logo160dpi, false);
addCanvasBitmap(layout, R.drawable.logo240dpi, false);
addLabelToRoot(root, "Autoscaled bitmap");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addResourceDrawable(layout, R.drawable.logonodpi120);
addResourceDrawable(layout, R.drawable.logonodpi160);
addResourceDrawable(layout, R.drawable.logonodpi240);
addLabelToRoot(root, "No-dpi resource drawable");
addChildToRoot(root, layout);
layout = new LinearLayout(this);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch120dpi);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch160dpi);
addNinePatchResourceDrawable(layout, R.drawable.smlnpatch240dpi);
addLabelToRoot(root, "Prescaled 9-patch resource drawable");
addChildToRoot(root, layout);
setContentView(scrollWrap(root));
}
use of android.widget.LinearLayout in project platform_frameworks_base by android.
the class ViewPropertyAlphaActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_properties);
getWindow().getDecorView().postDelayed(new Runnable() {
@Override
public void run() {
startAnim(R.id.button);
startAnim(R.id.textview);
startAnim(R.id.spantext);
startAnim(R.id.edittext);
startAnim(R.id.selectedtext);
startAnim(R.id.textviewbackground);
startAnim(R.id.layout);
startAnim(R.id.imageview);
startAnim(myViewAlphaDefault);
startAnim(myViewAlphaHandled);
EditText selectedText = (EditText) findViewById(R.id.selectedtext);
selectedText.setSelection(3, 8);
}
}, 2000);
Button invalidator = (Button) findViewById(R.id.invalidateButton);
invalidator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
findViewById(R.id.textview).invalidate();
findViewById(R.id.spantext).invalidate();
}
});
TextView textView = (TextView) findViewById(R.id.spantext);
if (textView != null) {
SpannableStringBuilder text = new SpannableStringBuilder("Now this is a short text message with spans");
text.setSpan(new BackgroundColorSpan(Color.RED), 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ForegroundColorSpan(Color.BLUE), 4, 9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new SuggestionSpan(this, new String[] { "longer" }, 3), 11, 16, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new UnderlineSpan(), 17, 20, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
text.setSpan(new ImageSpan(this, R.drawable.icon), 21, 22, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.setText(text);
}
LinearLayout container = (LinearLayout) findViewById(R.id.container);
myViewAlphaDefault = new MyView(this, false);
myViewAlphaDefault.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
container.addView(myViewAlphaDefault);
myViewAlphaHandled = new MyView(this, true);
myViewAlphaHandled.setLayoutParams(new LinearLayout.LayoutParams(75, 75));
container.addView(myViewAlphaHandled);
}
use of android.widget.LinearLayout in project platform_frameworks_base by android.
the class BigEditTextActivityNonScrollablePanScan method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
mRootView = new LinearLayout(this);
((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL);
mRootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
View view = getLayoutInflater().inflate(R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false);
((LinearLayout) mRootView).addView(view);
mDefaultFocusedView = view.findViewById(R.id.data);
setContentView(mRootView);
}
use of android.widget.LinearLayout in project platform_frameworks_base by android.
the class BigEditTextActivityNonScrollableResize method onCreate.
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
mRootView = new LinearLayout(this);
((LinearLayout) mRootView).setOrientation(LinearLayout.VERTICAL);
mRootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
View view = getLayoutInflater().inflate(R.layout.full_screen_edit_text, ((LinearLayout) mRootView), false);
((LinearLayout) mRootView).addView(view);
mDefaultFocusedView = view.findViewById(R.id.data);
setContentView(mRootView);
}
Aggregations