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);
}
}
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);
}
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;
}
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();
}
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));
}
}
});
}
Aggregations