use of android.widget.RelativeLayout.LayoutParams in project MaterialDesignLibrary by navasmdc.
the class ProgressBarDeterminate method setProgress.
public void setProgress(int progress) {
if (getWidth() == 0) {
pendindProgress = progress;
} else {
this.progress = progress;
if (progress > max)
progress = max;
if (progress < min)
progress = min;
int totalWidth = max - min;
double progressPercent = (double) progress / (double) totalWidth;
int progressWidth = (int) (getWidth() * progressPercent);
LayoutParams params = (LayoutParams) progressView.getLayoutParams();
params.width = progressWidth;
params.height = getHeight();
progressView.setLayoutParams(params);
pendindProgress = -1;
}
}
use of android.widget.RelativeLayout.LayoutParams in project Klyph by jonathangerbaud.
the class AmazonBanner method createAdView.
@Override
public View createAdView(Activity activity, ViewGroup adContainer, final IBannerCallback callback) {
Log.d("AmazonBanner", "createAdView: ");
final AdLayout adView = new AdLayout(activity, AdSize.SIZE_300x250);
adView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
adView.setListener(new com.amazon.device.ads.AdListener() {
@Override
public void onAdLoaded(AdLayout adView, AdProperties arg1) {
callback.onReceiveAd(adView);
}
@Override
public void onAdFailedToLoad(AdLayout adView, AdError error) {
callback.onFailedToReceiveAd(adView, error.getMessage());
}
@Override
public void onAdExpanded(AdLayout arg0) {
}
@Override
public void onAdCollapsed(AdLayout arg0) {
}
});
return adView;
}
use of android.widget.RelativeLayout.LayoutParams in project WordPress-Android by wordpress-mobile.
the class EditorFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_editor, container, false);
// Setup hiding the action bar when the soft keyboard is displayed for narrow viewports
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && !getResources().getBoolean(R.bool.is_large_tablet_landscape)) {
mHideActionBarOnSoftKeyboardUp = true;
}
// -- WebView configuration
mWebView = (EditorWebViewAbstract) view.findViewById(R.id.webview);
// Revert to compatibility WebView for custom ROMs using a 4.3 WebView in Android 4.4
if (mWebView.shouldSwitchToCompatibilityMode()) {
ViewGroup parent = (ViewGroup) mWebView.getParent();
int index = parent.indexOfChild(mWebView);
parent.removeView(mWebView);
mWebView = new EditorWebViewCompatibility(getActivity(), null);
mWebView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
parent.addView(mWebView, index);
}
mWebView.setOnTouchListener(this);
mWebView.setOnImeBackListener(this);
mWebView.setAuthHeaderRequestListener(this);
mWebView.setOnDragListener(mOnDragListener);
if (mCustomHttpHeaders != null && mCustomHttpHeaders.size() > 0) {
for (Map.Entry<String, String> entry : mCustomHttpHeaders.entrySet()) {
mWebView.setCustomHeader(entry.getKey(), entry.getValue());
}
}
// Ensure that the content field is always filling the remaining screen space
mWebView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
mWebView.post(new Runnable() {
@Override
public void run() {
mWebView.execJavaScriptFromString("try {ZSSEditor.refreshVisibleViewportSize();} catch (e) " + "{console.log(e)}");
}
});
}
});
mEditorFragmentListener.onEditorFragmentInitialized();
initJsEditor();
if (savedInstanceState != null) {
setTitle(savedInstanceState.getCharSequence(KEY_TITLE));
setContent(savedInstanceState.getCharSequence(KEY_CONTENT));
}
// -- HTML mode configuration
mSourceView = view.findViewById(R.id.sourceview);
mSourceViewTitle = (SourceViewEditText) view.findViewById(R.id.sourceview_title);
mSourceViewContent = (SourceViewEditText) view.findViewById(R.id.sourceview_content);
// Toggle format bar on/off as user changes focus between title and content in HTML mode
mSourceViewTitle.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
updateFormatBarEnabledState(!hasFocus);
}
});
mSourceViewTitle.setOnTouchListener(this);
mSourceViewContent.setOnTouchListener(this);
mSourceViewTitle.setOnImeBackListener(this);
mSourceViewContent.setOnImeBackListener(this);
mSourceViewContent.addTextChangedListener(new HtmlStyleTextWatcher());
mSourceViewTitle.setHint(mTitlePlaceholder);
mSourceViewContent.setHint("<p>" + mContentPlaceholder + "</p>");
// attach drag-and-drop handler
mSourceViewTitle.setOnDragListener(mOnDragListener);
mSourceViewContent.setOnDragListener(mOnDragListener);
// -- Format bar configuration
setupFormatBarButtonMap(view);
return view;
}
use of android.widget.RelativeLayout.LayoutParams in project LshUtils by SenhLinsh.
the class ViewUtils method getAbsListViewHeightBasedOnChildren.
/**
* 根据所有条目计算AbsListView的高
*/
public static int getAbsListViewHeightBasedOnChildren(AbsListView view) {
ListAdapter adapter;
if (view == null || (adapter = view.getAdapter()) == null) {
return 0;
}
int height = 0;
for (int i = 0; i < adapter.getCount(); i++) {
View item = adapter.getView(i, null, view);
if (item instanceof ViewGroup) {
item.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
item.measure(0, 0);
height += item.getMeasuredHeight();
}
height += view.getPaddingTop() + view.getPaddingBottom();
return height;
}
use of android.widget.RelativeLayout.LayoutParams in project platform_frameworks_base by android.
the class InstanceTargets method sendMessage.
public void sendMessage(final View view) {
TransitionManager.beginDelayedTransition(mSceneRoot, new ChangeBounds().addTarget(view));
for (int i = 0; i < mSceneRoot.getChildCount(); ++i) {
Button button = (Button) mSceneRoot.getChildAt(i);
LayoutParams params = (LayoutParams) button.getLayoutParams();
int[] rules = params.getRules();
if (rules[ALIGN_PARENT_RIGHT] != 0) {
params.removeRule(ALIGN_PARENT_RIGHT);
params.addRule(ALIGN_PARENT_LEFT);
} else {
params.removeRule(ALIGN_PARENT_LEFT);
params.addRule(ALIGN_PARENT_RIGHT);
}
button.setLayoutParams(params);
}
}
Aggregations