Search in sources :

Example 61 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project Material-Movies by saulmm.

the class MovieDetailActivity method showReviews.

/**
     * Creates a TextView with a Spannable format programmatically
     * containing the author by whom was the review written and the
     * review text
     *
     * @param reviewList a list containing reviews of the film
     */
@Override
public void showReviews(List<Review> reviewList) {
    final int reviewMarginTop = getResources().getDimensionPixelOffset(R.dimen.activity_vertical_margin_half);
    final LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(0, reviewMarginTop, 0, 0);
    movieHeaders.get(REVIEWS_HEADER).setVisibility(View.VISIBLE);
    for (Review result : reviewList) {
        // Creates a TextView
        TextView reviewTextView = new TextView(this);
        reviewTextView.setTextAppearance(this, R.style.MaterialMoviesReviewTextView);
        if (mReviewsColor != -1)
            reviewTextView.setTextColor(mReviewsColor);
        // Configure the review text
        String reviewCredit = "Review written by " + result.getAuthor();
        String reviewText = String.format("%s - %s", reviewCredit, result.getContent());
        Spannable spanColorString = new SpannableString(reviewText);
        spanColorString.setSpan(new ForegroundColorSpan(mReviewsAuthorColor), 0, reviewCredit.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        reviewTextView.setText(spanColorString);
        mMovieDescriptionContainer.addView(reviewTextView, layoutParams);
    }
}
Also used : SpannableString(android.text.SpannableString) LayoutParams(android.widget.LinearLayout.LayoutParams) ForegroundColorSpan(android.text.style.ForegroundColorSpan) TextView(android.widget.TextView) Review(com.hackvg.model.entities.Review) SpannableString(android.text.SpannableString) Spannable(android.text.Spannable)

Example 62 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by DirtyUnicorns.

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

Example 63 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class GlyphCacheActivity method createTextView.

private TextView createTextView() {
    TextView textview = new TextView(this);
    textview.setTextSize(6 + (int) (Math.random() * 5) * 10);
    textview.setTextColor(0xff << 24 | (int) (Math.random() * 255) << 16 | (int) (Math.random() * 255) << 8 | (int) (Math.random() * 255) << 16);
    textview.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    int numChars = 5 + (int) (Math.random() * 10);
    mTotalChars += numChars;
    textview.setText(createString(numChars));
    return textview;
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) TextView(android.widget.TextView)

Example 64 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by DirtyUnicorns.

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();
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Message(android.os.Message) Handler(android.os.Handler) WebView(android.webkit.WebView) LinearLayout(android.widget.LinearLayout)

Example 65 with LayoutParams

use of android.widget.LinearLayout.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class DelayedTransition method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.two_buttons);
    final Button button1 = (Button) findViewById(R.id.button1);
    final Button button2 = (Button) findViewById(R.id.button2);
    final LinearLayout container = (LinearLayout) findViewById(R.id.container);
    button1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            int buttonWidth = button1.getWidth();
            int containerWidth = container.getWidth();
            if (buttonWidth < containerWidth) {
                TransitionManager.beginDelayedTransition(container, null);
                button1.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
                TransitionManager.beginDelayedTransition(container, null);
                button2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
            } else {
                TransitionManager.beginDelayedTransition(container, null);
                button1.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
                TransitionManager.beginDelayedTransition(container, null);
                button2.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            }
        }
    });
}
Also used : LayoutParams(android.widget.LinearLayout.LayoutParams) Button(android.widget.Button) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Aggregations

LayoutParams (android.widget.LinearLayout.LayoutParams)78 LinearLayout (android.widget.LinearLayout)44 View (android.view.View)36 TextView (android.widget.TextView)24 ImageView (android.widget.ImageView)17 Button (android.widget.Button)16 ProgressBar (android.widget.ProgressBar)9 Message (android.os.Message)8 OnClickListener (android.view.View.OnClickListener)8 ScrollView (android.widget.ScrollView)7 Handler (android.os.Handler)6 ViewGroup (android.view.ViewGroup)6 WebView (android.webkit.WebView)6 HorizontalScrollView (android.widget.HorizontalScrollView)5 ChangeBounds (android.transition.ChangeBounds)4 Crossfade (android.transition.Crossfade)4 Scene (android.transition.Scene)4 TransitionSet (android.transition.TransitionSet)4 SurfaceView (android.view.SurfaceView)4 TextureView (android.view.TextureView)4