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


Java LinearLayout.setId方法代码示例

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


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

示例1: getPageBody

import android.widget.LinearLayout; //导入方法依赖的package包/类
private LinearLayout getPageBody() {
	llBody = new LinearLayout(getContext());
	llBody.setId(2);
	int resId = getBitmapRes(activity, "edittext_back");
	if (resId > 0) {
		llBody.setBackgroundResource(resId);
	}
	llBody.setOrientation(LinearLayout.VERTICAL);
	RelativeLayout.LayoutParams lpBody = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpBody.addRule(RelativeLayout.ALIGN_LEFT, llTitle.getId());
	lpBody.addRule(RelativeLayout.BELOW, llTitle.getId());
	lpBody.addRule(RelativeLayout.ALIGN_RIGHT, llTitle.getId());
	if (!dialogMode) {
		lpBody.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	}
	int dp_3 = dipToPx(getContext(), 3);
	lpBody.setMargins(dp_3, dp_3, dp_3, dp_3);
	llBody.setLayoutParams(lpBody);

	llBody.addView(getMainBody());
	llBody.addView(getSep());
	llBody.addView(getPlatformList());

	return llBody;
}
 
开发者ID:liupengandroid,项目名称:ywApplication,代码行数:27,代码来源:EditPage.java

示例2: onCreateView

import android.widget.LinearLayout; //导入方法依赖的package包/类
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Context context = getActivity();
    FrameLayout root = new FrameLayout(context);
    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(1);
    pframe.setVisibility(8);
    pframe.setGravity(17);
    pframe.addView(new ProgressBar(context, null, 16842874), new LayoutParams(-2, -2));
    root.addView(pframe, new LayoutParams(-1, -1));
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(17);
    lframe.addView(tv, new LayoutParams(-1, -1));
    ListView lv = new ListView(getActivity());
    lv.setId(16908298);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new LayoutParams(-1, -1));
    root.addView(lframe, new LayoutParams(-1, -1));
    root.setLayoutParams(new LayoutParams(-1, -1));
    return root;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:ListFragment.java

示例3: addItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);
	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
开发者ID:MedicationReminder,项目名称:MedicationReminder,代码行数:21,代码来源:SwipeMenuView.java

示例4: addItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void addItem(SwipeMenuItem item, int index) {
    LayoutParams params = new LayoutParams(item.getWidth(), item.getHeight());
    params.weight = item.getWeight();
    LinearLayout parent = new LinearLayout(getContext());
    parent.setId(index);
    parent.setGravity(Gravity.CENTER);
    parent.setOrientation(VERTICAL);
    parent.setLayoutParams(params);
    ResCompat.setBackground(parent, item.getBackground());
    parent.setOnClickListener(mMenuClickListener);
    addView(parent);

    if (item.getImage() != null)
        parent.addView(createIcon(item));

    if (!TextUtils.isEmpty(item.getText()))
        parent.addView(createTitle(item));
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:19,代码来源:SwipeMenuView.java

示例5: instantiateItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
    public Object instantiateItem(ViewGroup container, int position) {
        LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext()).inflate(R.layout.layout_child, null);
        //new LinearLayout(container.getContext());
        TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview);
        textView.setText(position + "");
        linearLayout.setId(R.id.item_id);
        switch (position) {
            case 0:
                linearLayout.setBackgroundColor(Color.parseColor("#2196F3"));
                break;
            case 1:
                linearLayout.setBackgroundColor(Color.parseColor("#673AB7"));
                break;
            case 2:
                linearLayout.setBackgroundColor(Color.parseColor("#009688"));
                break;
            case 3:
                linearLayout.setBackgroundColor(Color.parseColor("#607D8B"));
                break;
            case 4:
                linearLayout.setBackgroundColor(Color.parseColor("#F44336"));
                break;
        }
        container.addView(linearLayout);
//        linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics());
//        linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics());
        return linearLayout;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:UltraPagerAdapter.java

示例6: translucent

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * 此方法需在setContentView之后调用
 *
 * @param activity Activity
 * @param color    颜色
 */
public static void translucent(Activity activity, @ColorInt int color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        //Android4.4以下不支持沉浸式状态栏
        return;
    }
    LogUtils.verbose("let status bar immersion by color" + color);
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    View immersionView = decorView.findViewById(IMMERSION_ID);
    if (null != immersionView) {
        LogUtils.verbose("status bar has immersion");
        return;
    }
    View contentView = decorView.getChildAt(0);
    //The specified child already has a parent. You must call removeView() on the child's parent first.
    decorView.removeView(contentView);
    LinearLayout layout = new LinearLayout(activity);
    layout.setId(IMMERSION_ID);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setBackgroundColor(color);
    View stubView = new View(activity);//打桩一个和状态栏高度一致的视图
    int width = LinearLayout.LayoutParams.MATCH_PARENT;
    int height = obtainHeight(activity);
    stubView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
    layout.addView(stubView);
    layout.addView(contentView);
    decorView.addView(layout);
    translucent(activity, contentView);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:StatusBar.java

示例7: createClassicViews

import android.widget.LinearLayout; //导入方法依赖的package包/类
static void createClassicViews(RelativeLayout layout) {
    TextView textViewTitle = new TextView(layout.getContext());
    textViewTitle.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_title);
    textViewTitle.setTextSize(12);
    textViewTitle.setTextColor(Color.parseColor("#333333"));
    TextView textViewLastUpdate = new TextView(layout.getContext());
    textViewLastUpdate.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_last_update);
    textViewLastUpdate.setTextSize(10);
    textViewLastUpdate.setTextColor(Color.parseColor("#969696"));
    textViewLastUpdate.setVisibility(View.GONE);
    LinearLayout textContainer = new LinearLayout(layout.getContext());
    textContainer.setOrientation(LinearLayout.VERTICAL);
    textContainer.setGravity(Gravity.CENTER_HORIZONTAL);
    textContainer.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_text_container);
    LinearLayout.LayoutParams textViewTitleLP = new LinearLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainer.addView(textViewTitle, textViewTitleLP);
    LinearLayout.LayoutParams textViewLastUpdateLP = new LinearLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainer.addView(textViewLastUpdate, textViewLastUpdateLP);
    RelativeLayout.LayoutParams textContainerLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textContainerLP.addRule(RelativeLayout.CENTER_IN_PARENT);
    layout.addView(textContainer, textContainerLP);
    ImageView imageViewArrow = new ImageView(layout.getContext());
    imageViewArrow.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_arrow);
    RelativeLayout.LayoutParams imageViewArrowLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int dp6 = PixelUtl.dp2px(layout.getContext(), 6);
    imageViewArrowLP.setMargins(dp6, dp6, dp6, dp6);
    imageViewArrowLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
            .sr_classic_text_container);
    imageViewArrowLP.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(imageViewArrow, imageViewArrowLP);
    ProgressBar progressBar = new ProgressBar(layout.getContext(), null, android.R.attr
            .progressBarStyleSmallInverse);
    progressBar.setId(me.dkzwm.widget.srl.ext.classic.R.id.sr_classic_progress);
    RelativeLayout.LayoutParams progressBarLP = new RelativeLayout.LayoutParams(ViewGroup
            .LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    progressBarLP.setMargins(dp6, dp6, dp6, dp6);
    progressBarLP.addRule(RelativeLayout.LEFT_OF, me.dkzwm.widget.srl.ext.classic.R.id
            .sr_classic_text_container);
    progressBarLP.addRule(RelativeLayout.CENTER_VERTICAL);
    layout.addView(progressBar, progressBarLP);
}
 
开发者ID:dkzwm,项目名称:SmoothRefreshLayout,代码行数:46,代码来源:ClassicConfig.java

示例8: onCreate

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout view = new LinearLayout(this);
    //noinspection ResourceType
    view.setId(1);
    setContentView(view);
}
 
开发者ID:d4rken,项目名称:ommvplib,代码行数:9,代码来源:FragmentTestActivity.java

示例9: instantiateItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
    public Object instantiateItem(ViewGroup container, int position) {
        LinearLayout linearLayout = (LinearLayout) LayoutInflater.from(container.getContext()).inflate(R.layout.layout_child, null);
        //new LinearLayout(container.getContext());
        TextView textView = (TextView) linearLayout.findViewById(R.id.pager_textview);
        textView.setText(position + "");
        linearLayout.setId(R.id.item_id);
        switch (position) {
            case 0:
                linearLayout.setBackgroundColor(Color.parseColor("#2196F3"));
                break;
            case 1:
                linearLayout.setBackgroundColor(Color.parseColor("#673AB7"));
                break;
            case 2:
                linearLayout.setBackgroundColor(Color.parseColor("#009688"));
                break;
            case 3:
                linearLayout.setBackgroundColor(Color.parseColor("#607D8B"));
                break;
            case 4:
                linearLayout.setBackgroundColor(Color.parseColor("#F44336"));
                break;
        }
        linearLayout.setTag(TrackerConstants.VIEW_TAG_UNIQUE_NAME, "home_banner_item_" + position);
        Map<String, String> map = new HashMap();
        map.put("content", textView.getText().toString());
        linearLayout.setTag(TrackerConstants.VIEW_TAG_PARAM, map);
        container.addView(linearLayout);
//        linearLayout.getLayoutParams().width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 180, container.getContext().getResources().getDisplayMetrics());
//        linearLayout.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 400, container.getContext().getResources().getDisplayMetrics());
        return linearLayout;
    }
 
开发者ID:alibaba,项目名称:android_viewtracker,代码行数:34,代码来源:UltraPagerAdapter.java

示例10: onCreate

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final LinearLayout view = new LinearLayout(this);
    view.setId(1);

    setContentView(view);
}
 
开发者ID:dmitrikudrenko,项目名称:MDRXL,代码行数:9,代码来源:SupportFragmentControllerExt.java

示例11: initView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initView() {
    //初始化RecyclerView
    mRecyclerView = new SpeedRecyclerView(mContext);
    mRecyclerView.setId(R.id.banner_recycler);
    //以matchParent的方式将RecyclerView填充到控件容器中
    addView(mRecyclerView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    //创建指示器容器的相对布局
    RelativeLayout indicatorContainerRl = new RelativeLayout(mContext);
    //设置指示器容器Padding
    indicatorContainerRl.setPadding(UiUtils.dip2px(mContext,2), 0, UiUtils.dip2px(mContext,8), 0);
    //初始化指示器容器的布局参数
    LayoutParams indicatorContainerLp = new LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    // 设置指示器容器内的子view的布局方式
    indicatorContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    indicatorContainerLp.addRule(RelativeLayout.BELOW,R.id.banner_recycler);
    //将指示器容器添加到父View中
    addView(indicatorContainerRl, indicatorContainerLp);
    //初始化存放点的线性布局
    mPointContainerLl = new LinearLayout(mContext);
    //设置线性布局的id
    mPointContainerLl.setId(R.id.banner_pointContainerId);
    //设置线性布局的方向
    mPointContainerLl.setOrientation(LinearLayout.HORIZONTAL);
    //设置点容器的布局参数
    LayoutParams pointContainerLp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pointContainerLp.addRule(RelativeLayout.CENTER_IN_PARENT);
    //将点容器存放到指示器容器中
    indicatorContainerRl.addView(mPointContainerLl, pointContainerLp);
}
 
开发者ID:Zweihui,项目名称:Aurora,代码行数:30,代码来源:MyBanner.java

示例12: initView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(CENTER_VERTICAL);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);
        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:72,代码来源:BGABanner.java

示例13: initView

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void initView(Context context) {
    RelativeLayout pointContainerRl = new RelativeLayout(context);
    if (Build.VERSION.SDK_INT >= 16) {
        pointContainerRl.setBackground(mPointContainerBackgroundDrawable);
    } else {
        pointContainerRl.setBackgroundDrawable(mPointContainerBackgroundDrawable);
    }
    pointContainerRl.setPadding(mPointContainerLeftRightPadding, mPointTopBottomMargin, mPointContainerLeftRightPadding, mPointTopBottomMargin);
    LayoutParams pointContainerLp = new LayoutParams(RMP, RWC);
    // 处理圆点在顶部还是底部
    if ((mPointGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP) {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    } else {
        pointContainerLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    }
    addView(pointContainerRl, pointContainerLp);


    LayoutParams indicatorLp = new LayoutParams(RWC, RWC);
    indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    if (mIsNumberIndicator) {
        mNumberIndicatorTv = new TextView(context);
        mNumberIndicatorTv.setId(R.id.banner_indicatorId);
        mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
        mNumberIndicatorTv.setSingleLine(true);
        mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
        mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
        mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
        mNumberIndicatorTv.setVisibility(View.INVISIBLE);
        if (mNumberIndicatorBackground != null) {
            if (Build.VERSION.SDK_INT >= 16) {
                mNumberIndicatorTv.setBackground(mNumberIndicatorBackground);
            } else {
                mNumberIndicatorTv.setBackgroundDrawable(mNumberIndicatorBackground);
            }
        }
        pointContainerRl.addView(mNumberIndicatorTv, indicatorLp);
    } else {
        mPointRealContainerLl = new LinearLayout(context);
        mPointRealContainerLl.setId(R.id.banner_indicatorId);
        mPointRealContainerLl.setOrientation(LinearLayout.HORIZONTAL);
        mPointRealContainerLl.setGravity(Gravity.CENTER_VERTICAL);


        pointContainerRl.addView(mPointRealContainerLl, indicatorLp);
    }

    LayoutParams tipLp = new LayoutParams(RMP, RWC);
    tipLp.addRule(CENTER_VERTICAL);
    mTipTv = new TextView(context);
    mTipTv.setGravity(Gravity.CENTER_VERTICAL);
    mTipTv.setSingleLine(true);
    mTipTv.setEllipsize(TextUtils.TruncateAt.END);
    mTipTv.setTextColor(mTipTextColor);
    mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);
    pointContainerRl.addView(mTipTv, tipLp);

    int horizontalGravity = mPointGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    // 处理圆点在左边、右边还是水平居中
    if (horizontalGravity == Gravity.LEFT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        tipLp.addRule(RelativeLayout.RIGHT_OF, R.id.banner_indicatorId);
        mTipTv.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    } else if (horizontalGravity == Gravity.RIGHT) {
        indicatorLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    } else {
        indicatorLp.addRule(RelativeLayout.CENTER_HORIZONTAL);
        tipLp.addRule(RelativeLayout.LEFT_OF, R.id.banner_indicatorId);
    }

    showPlaceholder();
}
 
开发者ID:liu-xiao-dong,项目名称:JD-Test,代码行数:74,代码来源:BGABanner.java

示例14: onCreateView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
* Provide default implementation to return a simple list view. Subclasses
* can override to replace with their own layout. If doing so, the
* returned view hierarchy <em>must</em> have a ListView whose id
* is {@link android.R.id#list android.R.id.list} and can optionally
* have a sibling view id {@link android.R.id#empty android.R.id.empty}
* that is to be shown when the list is empty.
*
* <p>If you are overriding this method with your own custom content,
* consider including the standard layout {@link android.R.layout#list_content}
* in your layout file, so that you continue to retain all of the standard
* behavior of ListFragment. In particular, this is currently the only
* way to have the built-in indeterminant progress state be shown.
*/
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        final Context context = getActivity();

        FrameLayout root = new FrameLayout(context);

        // ------------------------------------------------------------------

        LinearLayout pframe = new LinearLayout(context);
        pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
        pframe.setOrientation(LinearLayout.VERTICAL);
        pframe.setVisibility(View.GONE);
        pframe.setGravity(Gravity.CENTER);

        ProgressBar progress = new ProgressBar(context, null,
                android.R.attr.progressBarStyleLarge);
        pframe.addView(progress, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

        root.addView(pframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        // ------------------------------------------------------------------

        FrameLayout lframe = new FrameLayout(context);
        lframe.setId(INTERNAL_LIST_CONTAINER_ID);

        TextView tv = new TextView(getActivity());
        tv.setId(INTERNAL_EMPTY_ID);
        tv.setGravity(Gravity.CENTER);
        lframe.addView(tv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        ExpandableListView lv = new ExpandableListView(getActivity());
        lv.setId(android.R.id.list);
        lv.setDrawSelectorOnTop(false);
        lframe.addView(lv, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        root.addView(lframe, new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        // ------------------------------------------------------------------

        root.setLayoutParams(new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        return root;
    }
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:65,代码来源:ExpandableListFragment.java

示例15: onCreateView

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Provide default implementation to return a simple grid view.  Subclasses
 * can override to replace with their own layout.  If doing so, the
 * returned view hierarchy <em>must</em> have a HeaderGridView whose id
 * is {@link android.R.id#list android.R.id.list} and can optionally
 * have a sibling view id {@link android.R.id#empty android.R.id.empty}
 * that is to be shown when the grid is empty.
 * 
 * <p>If you are overriding this method with your own custom content,
 * consider including the standard layout {@link android.R.layout#list_content}
 * in your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment.  In particular, this is currently the only
 * way to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null,
            android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    // ------------------------------------------------------------------

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    
    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    HeaderGridView lv = new HeaderGridView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(lv, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    
    return root;
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:65,代码来源:HeaderGridCompatFragment.java


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