Search in sources :

Example 56 with LinearLayout

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);
}
Also used : Bitmap(android.graphics.Bitmap) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 57 with LinearLayout

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));
}
Also used : LayoutInflater(android.view.LayoutInflater) LinearLayout(android.widget.LinearLayout)

Example 58 with LinearLayout

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);
}
Also used : EditText(android.widget.EditText) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TextView(android.widget.TextView) View(android.view.View) UnderlineSpan(android.text.style.UnderlineSpan) Button(android.widget.Button) TextView(android.widget.TextView) SuggestionSpan(android.text.style.SuggestionSpan) SpannableStringBuilder(android.text.SpannableStringBuilder) BackgroundColorSpan(android.text.style.BackgroundColorSpan) LinearLayout(android.widget.LinearLayout) ImageSpan(android.text.style.ImageSpan)

Example 59 with LinearLayout

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);
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 60 with LinearLayout

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);
}
Also used : ViewGroup(android.view.ViewGroup) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Aggregations

LinearLayout (android.widget.LinearLayout)1205 View (android.view.View)473 TextView (android.widget.TextView)455 ViewGroup (android.view.ViewGroup)203 ImageView (android.widget.ImageView)196 Button (android.widget.Button)167 ScrollView (android.widget.ScrollView)125 ListView (android.widget.ListView)100 LayoutInflater (android.view.LayoutInflater)90 FrameLayout (android.widget.FrameLayout)85 Context (android.content.Context)80 AdapterView (android.widget.AdapterView)74 EditText (android.widget.EditText)74 Intent (android.content.Intent)66 AbsListView (android.widget.AbsListView)58 LayoutParams (android.widget.LinearLayout.LayoutParams)48 RelativeLayout (android.widget.RelativeLayout)48 Bitmap (android.graphics.Bitmap)46 OnClickListener (android.view.View.OnClickListener)44 Drawable (android.graphics.drawable.Drawable)42