Search in sources :

Example 46 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project Klyph by jonathangerbaud.

the class PostPhotos method updateLayout.

public void updateLayout() {
    if (getGridView() != null && getGridView().getAdapter() != null) {
        LayoutParams params = getGridView().getLayoutParams();
        if (KlyphDevice.isLandscapeMode() || getGridView().getAdapter().getCount() <= getNumColumn()) {
            params.height = (int) ((KlyphDevice.getDeviceWidth() - (48 + 8 + 2) * KlyphDevice.getDeviceDensity()) / getNumColumn());
        } else {
            params.height = (int) ((KlyphDevice.getDeviceWidth() - (48 + 8 + 2) * KlyphDevice.getDeviceDensity()) / (getNumColumn() / 2));
        }
        getGridView().setLayoutParams(params);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams)

Example 47 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project ViewPagerIndicator by LuckyJayce.

the class LazyFragment method onCreateView.

@Deprecated
protected final void onCreateView(Bundle savedInstanceState) {
    super.onCreateView(savedInstanceState);
    this.savedInstanceState = savedInstanceState;
    Bundle bundle = getArguments();
    if (bundle != null) {
        isLazyLoad = bundle.getBoolean(INTENT_BOOLEAN_LAZYLOAD, isLazyLoad);
    }
    //为什么不直接getUserVisibleHint();而是通过自己存isVisibleToUserState变量判断
    //因为v4的25的版本 已经调用 setUserVisibleHint(true),结果到这里getUserVisibleHint是false
    // (ps:看了FragmentManager源码Fragment被重新创建有直接赋值isVisibleToUser不知道是不是那里和之前v4有改动的地方)
    //所以我默认VISIBLE_STATE_NOTSET,之前没有调用setUserVisibleHint方法,就用系统的getUserVisibleHint,否则就用setUserVisibleHint后保存的值
    //总之就是调用了setUserVisibleHint 就使用setUserVisibleHint的值
    boolean isVisibleToUser;
    if (isVisibleToUserState == VISIBLE_STATE_NOTSET) {
        isVisibleToUser = getUserVisibleHint();
    } else {
        isVisibleToUser = isVisibleToUserState == VISIBLE_STATE_VISIABLE;
    }
    if (isLazyLoad) {
        if (isVisibleToUser && !isInit) {
            isInit = true;
            onCreateViewLazy(savedInstanceState);
        } else {
            LayoutInflater layoutInflater = inflater;
            if (layoutInflater == null) {
                layoutInflater = LayoutInflater.from(getApplicationContext());
            }
            layout = new FrameLayout(layoutInflater.getContext());
            View view = getPreviewLayout(layoutInflater, layout);
            if (view != null) {
                layout.addView(view);
            }
            layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            super.setContentView(layout);
        }
    } else {
        isInit = true;
        onCreateViewLazy(savedInstanceState);
    }
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Bundle(android.os.Bundle) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) View(android.view.View)

Example 48 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project phonegap-facebook-plugin by Wizcorp.

the class CordovaChromeClient method getVideoLoadingProgressView.

@Override
public /**
     * Ask the host application for a custom progress view to show while
     * a <video> is loading.
     * @return View The progress view.
     */
View getVideoLoadingProgressView() {
    if (mVideoProgressView == null) {
        // Create a new Loading view programmatically.
        // create the linear layout
        LinearLayout layout = new LinearLayout(this.appView.getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        layout.setLayoutParams(layoutParams);
        // the proress bar
        ProgressBar bar = new ProgressBar(this.appView.getContext());
        LinearLayout.LayoutParams barLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        barLayoutParams.gravity = Gravity.CENTER;
        bar.setLayoutParams(barLayoutParams);
        layout.addView(bar);
        mVideoProgressView = layout;
    }
    return mVideoProgressView;
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) RelativeLayout(android.widget.RelativeLayout) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout)

Example 49 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project storymaker by StoryMaker.

the class ProjectTagFragment method displayTag.

/**
	 * Display a tag with text equal to "#" + tag, and View#tag equal 
	 * to tag's String value.
	 * 
	 * Does not add tag to the Project represented by this Fragment
	 */
private void displayTag(String tag) {
    Button btnTag = new Button(getActivity());
    btnTag.setEnabled(mEditable);
    btnTag.setText("#" + tag);
    btnTag.setTag(tag);
    btnTag.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    btnTag.setOnClickListener(mInternalOnTagClickListener);
    if (mSpecialMessageTv != null) {
        mContainerProjectTagsView.removeView(mSpecialMessageTv);
    }
    mContainerProjectTagsView.addView(btnTag, 0);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) Button(android.widget.Button)

Example 50 with LayoutParams

use of android.view.ViewGroup.LayoutParams in project storymaker by StoryMaker.

the class ProjectTagFragment method displayMessage.

/**
	 * Display a message in a view that spans the entire
	 * tag pool
	 */
private void displayMessage(String message) {
    TextView textView = new TextView(getActivity());
    textView.setText(message);
    textView.setGravity(Gravity.CENTER);
    textView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    mSpecialMessageTv = textView;
    mContainerProjectTagsView.addView(textView, 0);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) TextView(android.widget.TextView)

Aggregations

LayoutParams (android.view.ViewGroup.LayoutParams)265 TextView (android.widget.TextView)56 View (android.view.View)50 ViewGroup (android.view.ViewGroup)50 FrameLayout (android.widget.FrameLayout)35 LinearLayout (android.widget.LinearLayout)33 ImageView (android.widget.ImageView)30 Test (org.junit.Test)26 Paint (android.graphics.Paint)22 ListView (android.widget.ListView)22 ScrollView (android.widget.ScrollView)22 Context (android.content.Context)19 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)19 AdapterView (android.widget.AdapterView)17 RelativeLayout (android.widget.RelativeLayout)14 DisplayMetrics (android.util.DisplayMetrics)12 CheckedTextView (android.widget.CheckedTextView)12 Rect (android.graphics.Rect)9 ViewParent (android.view.ViewParent)9 TypedArray (android.content.res.TypedArray)8