Search in sources :

Example 11 with LayoutParams

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

Example 12 with LayoutParams

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;
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) AdLayout(com.amazon.device.ads.AdLayout) AdProperties(com.amazon.device.ads.AdProperties) AdError(com.amazon.device.ads.AdError)

Example 13 with LayoutParams

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;
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) ViewGroup(android.view.ViewGroup) SpannableString(android.text.SpannableString) View(android.view.View) WebView(android.webkit.WebView) SuppressLint(android.annotation.SuppressLint) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap)

Example 14 with LayoutParams

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;
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) ViewGroup(android.view.ViewGroup) View(android.view.View) AbsListView(android.widget.AbsListView) ListView(android.widget.ListView) ListAdapter(android.widget.ListAdapter) Point(android.graphics.Point)

Example 15 with LayoutParams

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);
    }
}
Also used : LayoutParams(android.widget.RelativeLayout.LayoutParams) Button(android.widget.Button) ChangeBounds(android.transition.ChangeBounds)

Aggregations

LayoutParams (android.widget.RelativeLayout.LayoutParams)22 RelativeLayout (android.widget.RelativeLayout)8 View (android.view.View)7 ChangeBounds (android.transition.ChangeBounds)4 ViewGroup (android.view.ViewGroup)4 Button (android.widget.Button)4 AbsListView (android.widget.AbsListView)3 ListAdapter (android.widget.ListAdapter)3 ListView (android.widget.ListView)3 TextView (android.widget.TextView)3 Point (android.graphics.Point)2 SpannableString (android.text.SpannableString)2 LayoutInflater (android.view.LayoutInflater)2 Animation (android.view.animation.Animation)2 AnimationListener (android.view.animation.Animation.AnimationListener)2 Transformation (android.view.animation.Transformation)2 InputMethodManager (android.view.inputmethod.InputMethodManager)2 GridView (android.widget.GridView)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1