当前位置: 首页>>代码示例>>Java>>正文


Java LinearLayout.LayoutParams方法代码示例

本文整理汇总了Java中android.widget.LinearLayout.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayout.LayoutParams方法的具体用法?Java LinearLayout.LayoutParams怎么用?Java LinearLayout.LayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.LinearLayout的用法示例。


在下文中一共展示了LinearLayout.LayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSpecimenDetailsButton

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void createSpecimenDetailsButton() {
    int margin = UiUtils.dipToPixels(getActivity(), 10);

    Button button = new Button(getActivity());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(margin, margin, margin, margin);
    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.button);
    button.setText(R.string.specimen_details);
    mViewContainer.addView(button);

    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), SrvaSpecimenActivity.class);
            intent.putExtra(SrvaSpecimenActivity.EXTRA_SRVA_EVENT, mSrvaEvent);
            intent.putExtra(SrvaSpecimenActivity.EXTRA_EDIT_MODE, isEditModeOn());
            startActivityForResult(intent, SPECIMEN_REQUEST_CODE);
        }
    });
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:22,代码来源:SrvaEditFragment.java

示例2: notifyDataSetChanged

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void notifyDataSetChanged(){

        removeAllViews();
        if(mDatas == null || mDatas.size() == 0){
            return;
        }
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        for(int i=0; i<mDatas.size(); i++){
            final int index = i;
            View view = getView(index);
            if(view == null){
                throw new NullPointerException("listview item layout is null, please check getView()...");
            }

            addView(view, index, layoutParams);
        }

    }
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:19,代码来源:CommentListView.java

示例3: initBottom

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px_1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px_1);
	llBottom.addView(v, lp);
}
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:41,代码来源:EditPagePort.java

示例4: init

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void init() {
    this.setOverScrollMode(OVER_SCROLL_NEVER);
    this.setHorizontalScrollBarEnabled(false);

    mInflater = LayoutInflater.from(getContext());

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    mLayout = new LinearLayout(getContext());
    mLayout.setPadding(1, 0, 1, 0);
    mLayout.setOrientation(LinearLayout.HORIZONTAL);
    addView(mLayout, params);
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:13,代码来源:TabIconView.java

示例5: setItemWidth

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void setItemWidth(View itemView, int itemWidth) {
    LinearLayout.LayoutParams itemLp;
    if (itemView.getLayoutParams() != null) {
        itemLp = (LinearLayout.LayoutParams) itemView.getLayoutParams();
        itemLp.width = itemWidth;
    } else {
        itemLp = new LinearLayout.LayoutParams(itemWidth, ViewGroup.LayoutParams.WRAP_CONTENT);
        itemView.setLayoutParams(itemLp);
    }
    itemLp.gravity = Gravity.TOP;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:12,代码来源:QMUIBottomSheet.java

示例6: getView

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    try {
        GridViewHolder gridViewHolder = null;
        if (null == convertView && null != context) {
            gridViewHolder = new GridViewHolder();
            convertView = gridViewHolder.layoutView;
            if (convertView != null) {
                convertView.setTag(gridViewHolder);
            }
        } else {
            gridViewHolder = (GridViewHolder) convertView.getTag();
        }
        if (null == gridViewHolder || null == convertView) {
            return null;
        }
        gridViewHolder.faceIv.setImageBitmap(getBitmap(position));

        if (position == emoResIds.length - 1) {
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
            params.topMargin = CommonUtil.getElementSzie(context) / 3;
            gridViewHolder.faceIv.setLayoutParams(params);
        }
        return convertView;
    } catch (Exception e) {
        logger.e(e.getMessage());
        return null;
    }
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:31,代码来源:EmoGridViewAdapter.java

示例7: instantiateItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
    //如果要自定义ItemView在这里操作
    ImageView imageView = new ImageView(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(params);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    View v = null;
    if (mGalleyCycleImageListener != null)
        v = mGalleyCycleImageListener.setItem(imageView, getPosition(position));
    container.addView(v);
    return v;
}
 
开发者ID:wheat7,项目名称:GalleryCycleImageView,代码行数:14,代码来源:GalleryCycleImageView.java

示例8: addView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 向Snackbar中添加view
 *
 * @param snackbar
 * @param layoutId
 * @param index    新加布局在Snackbar中的位置
 */
public static void addView(Snackbar snackbar, int layoutId, int index) {
    View snackbarview = snackbar.getView();
    Snackbar.SnackbarLayout snackbarLayout = (Snackbar.SnackbarLayout) snackbarview;

    View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId, null);

    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
            .WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.gravity = Gravity.CENTER_VERTICAL;

    snackbarLayout.addView(add_view, index, p);
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:20,代码来源:SnackbarUtils.java

示例9: generateTitleViewAndSubTitleViewLp

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 生成 titleView 或 subTitleView 的 LayoutParams
 */
private LinearLayout.LayoutParams generateTitleViewAndSubTitleViewLp() {
    LinearLayout.LayoutParams titleLp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    // 垂直居中
    titleLp.gravity = mTitleGravity;
    return titleLp;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:10,代码来源:QMUITopBar.java

示例10: initBottom

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:41,代码来源:EditPageLand.java

示例11: createStatusBarView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private static StatusBarView createStatusBarView(Activity activity, int color, int alpha) {
    // 绘制一个和状态栏一样高的矩形
    StatusBarView statusBarView = new StatusBarView(activity);
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
    statusBarView.setLayoutParams(params);
    statusBarView.setBackgroundColor(calculateStatusColor(color, alpha));
    return statusBarView;
}
 
开发者ID:paterWang,项目名称:EasyReader,代码行数:10,代码来源:StatusBarUtils.java

示例12: createTranslucentStatusBarView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 创建半透明矩形 View
 *
 * @param alpha 透明值
 * @return 半透明 View
 */
private static StatusBarView createTranslucentStatusBarView(Activity activity, int alpha) {
    // 绘制一个和状态栏一样高的矩形
    StatusBarView statusBarView = new StatusBarView(activity);
    LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, getStatusBarHeight(activity));
    statusBarView.setLayoutParams(params);
    statusBarView.setBackgroundColor(Color.argb(alpha, 0, 0, 0));
    statusBarView.setId(FAKE_TRANSLUCENT_VIEW_ID);
    return statusBarView;
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:17,代码来源:XStatusBar.java

示例13: TrafficMeterAbstract

import android.widget.LinearLayout; //导入方法依赖的package包/类
protected TrafficMeterAbstract(Context context) {
    super(context);

    LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    mMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2,
            context.getResources().getDisplayMetrics());
    lParams.setMarginStart(mMargin);
    lParams.setMarginEnd(mMargin);
    setLayoutParams(lParams);
    setTextAppearance(context.getResources().getIdentifier(
            "TextAppearance.StatusBar.Clock", "style", PACKAGE_NAME));
    setGravity(Gravity.END | Gravity.CENTER_VERTICAL);

    if (!Utils.isWifiOnly(getContext())) {
        mPhone = (TelephonyManager) getContext().getSystemService(Context.TELEPHONY_SERVICE);
        mPhoneStateListener = new PhoneStateListener() {
            @Override
            public void onDataConnectionStateChanged(int state, int networkType) {
                final boolean connected = state == TelephonyManager.DATA_CONNECTED;
                if (mMobileDataConnected != connected) {
                    mMobileDataConnected = connected;
                    if (DEBUG)
                        log("onDataConnectionStateChanged: mMobileDataConnected=" + mMobileDataConnected);
                    updateState();
                }

            }
        };
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:32,代码来源:TrafficMeterAbstract.java

示例14: populate

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void populate(final boolean enabled, List<DeviceActionDAO> defaultActions, List<StoryDeviceActionDAO> existingActions) {
    LinearLayout layout;
    if (enabled) {
        layout = findViewById(R.id.storyEnabledLinearLayout);
    } else {
        layout = findViewById(R.id.storyDisabledLinearLayout);
    }
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 8, 0, 8);
    for (final DeviceActionDAO action : defaultActions) {
        Switch s = new Switch(this);
        s.setText(action.getName());
        s.setLayoutParams(lp);
        // Check the matching switch for every list
        for (StoryDeviceActionDAO existingAction : existingActions) {
            if (enabled && existingAction.isEnabled() && existingAction.getActionId() == action.getId()) {
                s.setChecked(true);
                break;
            } else if (!enabled && !existingAction.isEnabled() && existingAction.getActionId() == action.getId()) {
                s.setChecked(true);
                break;
            }
        }
        layout.addView(s);
        s.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
                if (checked) {
                    db.createActionForStoryAndDevice(storyId, enabled, action);
                } else {
                    db.deleteActionForStoryAndDevice(storyId, enabled, action);
                }
            }
        });
    }
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:37,代码来源:DeviceActivity.java

示例15: SnackbarAddView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 向Snackbar中添加view
 * @param snackbar
 * @param layoutId
 * @param index 新加布局在Snackbar中的位置
 */
public static void SnackbarAddView( Snackbar snackbar,int layoutId,int index) {
    View snackbarview = snackbar.getView();
    Snackbar.SnackbarLayout snackbarLayout=(Snackbar.SnackbarLayout)snackbarview;

    View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId,null);

    LinearLayout.LayoutParams p = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.gravity= Gravity.CENTER_VERTICAL;

    snackbarLayout.addView(add_view,index,p);
}
 
开发者ID:orchidTJJ,项目名称:getword,代码行数:18,代码来源:SnackbarUtil.java


注:本文中的android.widget.LinearLayout.LayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。