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


Java LinearLayoutCompat类代码示例

本文整理汇总了Java中android.support.v7.widget.LinearLayoutCompat的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutCompat类的具体用法?Java LinearLayoutCompat怎么用?Java LinearLayoutCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: init

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
/**
 * 初始化默认的HeaderView 与 FooterView
 *
 * @param context
 */
private void init(Context context) {
    // inflate得到的view需要代码设置LayoutParams
    // HeaderView
    mHeaderView = LinearLayoutCompat.inflate(context, R.layout.recyclerview_refresh_headerview, null);
    mHeaderViewStateIcon = mHeaderView.findViewById(R.id.refresh_headerview_stateIcon);
    mHeaderViewHint = (TextView) mHeaderView.findViewById(R.id.refresh_headerview_hint);
    mHeaderViewLastRefreshTime = (TextView) mHeaderView.findViewById(R.id.refresh_headerview_lastRefreshTime);

    // 直接从布局中获取高度即可
    mHeaderViewHeight = getResources().getDimensionPixelOffset(R.dimen.recyclerview_refresh_headerview_height);

    // 这里需要手动设置LayoutParams,否则getLayoutParams为空
    // 并且,在使用inflate得到的布局,没有设置手动设置LayoutParams的情况下,有些布局会出问题,特别是使用LinearLayout时。
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mHeaderViewHeight);
    lp.setMargins(0, -mHeaderViewHeight, 0, 0);
    mHeaderView.setLayoutParams(lp);
    mHeaderView.requestLayout();

    // FooterView
    mFooterView = LinearLayoutCompat.inflate(context, R.layout.recyclerview_refresh_footerview, null);
    mFooterViewStateIcon = mFooterView.findViewById(R.id.refresh_footerview_stateIcon);
    mFooterViewHint = (TextView) mFooterView.findViewById(R.id.refresh_footerview_hint);
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:29,代码来源:RefreshRecyclerView.java

示例2: showEvents

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
@Override
    public void showEvents(List<DetailEvent> events) {
        int headerHeight = getResources().getDimensionPixelSize(R.dimen.header_bg_height);
        rvDetailEvents.setLayoutManager(new LinearLayoutManager(getActivity()));
        mAdapter = new DetailEventAdapter(events, headerHeight);
        View view = new View(getActivity());
        view.setLayoutParams(new LinearLayoutCompat.LayoutParams(-1, headerHeight));
        mAdapter.addHeaderView(view);
        rvDetailEvents.setAdapter(mAdapter);
//        final StickyRecyclerHeadersDecoration header = new StickyRecyclerHeadersDecoration(mAdapter);
//        rvDetailEvents.addItemDecoration(header);
        rvDetailEvents.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
        rvDetailEvents.setItemAnimator(new SlideInLeftAnimator());
        rvDetailEvents.getItemAnimator().setAddDuration(500);
        rvDetailEvents.getItemAnimator().setRemoveDuration(500);
    }
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:17,代码来源:DetailEventsFragment.java

示例3: initBottomSheetItem

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
private void initBottomSheetItem() {
    LinearLayoutCompat takePhoto = mView.findViewById(R.id.bottom_sheet_item_take_photo);
    LinearLayoutCompat chooseImage = mView.findViewById(R.id.bottom_sheet_item_choose_image);
    LinearLayoutCompat recording = mView.findViewById(R.id.bottom_sheet_item_recording);
    LinearLayoutCompat moveToTrash = mView.findViewById(R.id.bottom_sheet_item_move_to_trash);
    LinearLayoutCompat permanentDelete = mView.findViewById(R.id.bottom_sheet_item_permanent_delete);
    LinearLayoutCompat makeACopy = mView.findViewById(R.id.bottom_sheet_item_make_a_copy);
    LinearLayoutCompat send = mView.findViewById(R.id.bottom_sheet_item_send);
    takePhoto.setOnClickListener(this);
    chooseImage.setOnClickListener(this);
    recording.setOnClickListener(this);
    moveToTrash.setOnClickListener(this);
    permanentDelete.setOnClickListener(this);
    makeACopy.setOnClickListener(this);
    send.setOnClickListener(this);
}
 
开发者ID:Art2Cat,项目名称:MoonlightNote,代码行数:17,代码来源:MoonlightDetailFragment.java

示例4: initMenuItems

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
private void initMenuItems()
{
    for (int i = 0; i < getChildCount() - 1; i++)
    {
        View item = getChildAt(i);
        item.setOnClickListener(new OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                if(null !=mOnMenuItemClickListener)
                {
                    mOnMenuItemClickListener.onMenuItemClick((FloatingActionButton) view,view.getId());
                }
                collapse();
            }
        });
        LayoutParams params = (LinearLayoutCompat.LayoutParams) item.getLayoutParams();
        params.topMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);
    }
}
 
开发者ID:lynnchurch,项目名称:FloatingActionButtonMenu,代码行数:22,代码来源:FloatingActionButtonMenu.java

示例5: oaDialog

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
public oaDialog(Context context, final Tools.oaCallBack callBack) {
    super(context);
    super.requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.setContentView(R.layout.custom_dialog);
    DisplayMetrics metrics = context.getResources().getDisplayMetrics();
    int width = metrics.widthPixels;
    super.getWindow().setLayout(width - 10, LinearLayoutCompat.LayoutParams.WRAP_CONTENT);

    relativeLayout = find(R.id.layout_actionbar);
    imageTitle = find(R.id.imagetitle);
    text = find(R.id.contenttext);
    inputlayout = find(R.id.textinputlayout);
    ((Button) find(R.id.button_ok)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            callBack.returnString(text.getText().toString());
            oaDialog.super.dismiss();
        }
    });

}
 
开发者ID:optimdz,项目名称:oasis,代码行数:22,代码来源:oaDialog.java

示例6: onCreateView

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_episode, container, false);

    img_thmb = (ImageView) view.findViewById(R.id.img_thumb);
    txt_name = (TextView) view.findViewById(R.id.txt_name);
    txt_date = (TextView) view.findViewById(R.id.txt_date);
    txt_plot = (TextView) view.findViewById(R.id.txt_plot);
    txt_subs = (TextView) view.findViewById(R.id.txt_subs);
    box_gues = (LinearLayoutCompat) view.findViewById(R.id.box_gues);
    txt_gues = (TextView) view.findViewById(R.id.txt_guests);
    box_writ = (LinearLayoutCompat) view.findViewById(R.id.box_writ);
    txt_writ = (TextView) view.findViewById(R.id.txt_writers);
    box_dire = (LinearLayoutCompat) view.findViewById(R.id.box_dire);
    txt_dire = (TextView) view.findViewById(R.id.txt_director);

    return view;
}
 
开发者ID:tarzasai,项目名称:Uoccin,代码行数:19,代码来源:EpisodeFragment.java

示例7: init

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
private void init(Context context, int childCount) {
    LinearLayoutCompat.LayoutParams layoutParams = new LinearLayoutCompat.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER_VERTICAL;
    this.setLayoutParams(layoutParams);

    this.childCount = childCount;
    this.setOrientation(LinearLayoutCompat.VERTICAL);

    if (this.childCount > 0) {
        LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams((CircleAppConstants.viewHeight)/ 5, (CircleAppConstants.viewHeight) / 5);
        childParams.gravity = Gravity.CENTER_VERTICAL|Gravity.CENTER_HORIZONTAL;
        for(int i = 0; i< this.childCount; i++){
            ChildCircleContainer childCircleContainer = new ChildCircleContainer(getContext(), (CircleAppConstants.viewHeight),onChildClick);
            childCircleContainer.setPadding(10,10,10,10);
            childCircleContainer.setLayoutParams(childParams);
            this.addView(childCircleContainer);
        }

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

示例8: addTab

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
public void addTab(android.support.v7.app.ActionBar.Tab tab, int i, boolean flag)
{
    tab = createTabView(tab, false);
    mTabLayout.addView(tab, i, new android.support.v7.widget.LinearLayoutCompat.LayoutParams(0, -1, 1.0F));
    if (mTabSpinner != null)
    {
        ((TabAdapter)mTabSpinner.getAdapter()).notifyDataSetChanged();
    }
    if (flag)
    {
        tab.setSelected(true);
    }
    if (mAllowCollapse)
    {
        requestLayout();
    }
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:18,代码来源:ScrollingTabContainerView.java

示例9: toViewPager

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
/**
 * transform to ViewPager
 *
 * @param recyclerView {@link RecyclerView}
 * @param orientation  the orientation of Linearlayout
 */
public static void toViewPager(RecyclerView recyclerView
        , @LinearLayoutCompat.OrientationMode int orientation) {
    recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()
            , orientation, false));
    new PagerSnapHelper().attachToRecyclerView(recyclerView);
}
 
开发者ID:arjinmc,项目名称:ExpandRecyclerView,代码行数:13,代码来源:RecyclerViewStyleHelper.java

示例10: init

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BackgroundProgress);
    try {
        showTxt = typedArray.getString(R.styleable.BackgroundProgress_showTxt);
        isGradient = typedArray.getBoolean(R.styleable.BackgroundProgress_isGradient, true);
    } catch (Exception e) {
        showTxt = null;
        isGradient = true;
    }

    typedArray.recycle();

    View view = LayoutInflater.from(context).inflate(R.layout.bp, null);

    backgroundProgressView = (BackgroundProgressView) view.findViewById(R.id.progress);
    tv = (TextView) view.findViewById(R.id.tv);

    if (TextUtils.isEmpty(showTxt)) {
        tv.setVisibility(GONE);
    } else {
        tv.setText(showTxt);
    }

    backgroundProgressView.set_isGradient(isGradient);


    ViewGroup.LayoutParams layoutParams = new LinearLayoutCompat.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    addView(view, layoutParams);
}
 
开发者ID:linheimx,项目名称:BackgroundProgress,代码行数:30,代码来源:BackgroundProgress.java

示例11: onCreateHeaderViewHolder

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
@Override
public RecyclerView.ViewHolder onCreateHeaderViewHolder(ViewGroup parent) {
    View view = new View(parent.getContext());
    view.setLayoutParams(new LinearLayoutCompat.LayoutParams(-1, headerHeight));
    return new RecyclerView.ViewHolder(view) {
    };
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:8,代码来源:DetailEventAdapter.java

示例12: onCreate

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_right_sample);

    sv = (StretchView) findViewById(R.id.sv);
    sv.setDrawHelper(new ArcDrawHelper(sv, ContextCompat.getColor(RightSampleActivity.this, R.color.colorPrimary), 40));

    rcv = (RecyclerView) findViewById(R.id.rcv);
    rcv.setLayoutManager(new LinearLayoutManager(RightSampleActivity.this, LinearLayoutManager.HORIZONTAL, false));
    rcv.addItemDecoration(new RcvDecoration(0, (int) getResources().getDimension(R.dimen.divider_horzontal), LinearLayoutCompat.HORIZONTAL));
    rcv.setAdapter(new RecyclerView.Adapter() {
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            return new VH(LayoutInflater.from(RightSampleActivity.this).inflate(R.layout.item_horizontal, parent, false));
        }

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        }

        @Override
        public int getItemCount() {
            return 10;
        }
    });
}
 
开发者ID:thunderpunch,项目名称:StretchView,代码行数:29,代码来源:RightSampleActivity.java

示例13: getItemTopSpacing

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
/**
 * get the item_vertical top spacing
 *
 * @param itemPosition itemPosition
 * @return int
 */
private int getItemTopSpacing(int itemPosition) {
    if (isFirstItem(itemPosition) && orientation == LinearLayoutCompat.VERTICAL) {
        return verticalItemSpacingInPx;
    }
    return verticalItemSpacingInPx >> 1;
}
 
开发者ID:thunderpunch,项目名称:StretchView,代码行数:13,代码来源:RcvDecoration.java

示例14: onChage

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
@SuppressWarnings("unchecked") private void onChage() {
  removeAllViews();

  for (int i = 0; i < mTAdapter.getCount(); ++i) {
    View tabView = mTAdapter.getView(i, this, mTAdapter.getItem(i));

    LinearLayoutCompat.LayoutParams layoutParams = new LayoutParams(0, -1);
    layoutParams.weight = 1;

    addView(tabView, i, layoutParams);
  }

  invalidate();
}
 
开发者ID:BoBoMEe,项目名称:Tab_Navigator,代码行数:15,代码来源:TabContainer.java

示例15: ReviewLabelsView

import android.support.v7.widget.LinearLayoutCompat; //导入依赖的package包/类
public ReviewLabelsView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setOrientation(HORIZONTAL);

    mAccount = Preferences.getAccount(context);

    // Separate labels and scores
    mLabelsLayout = new LinearLayout(context);
    mLabelsLayout.setOrientation(LinearLayout.VERTICAL);
    addView(mLabelsLayout, new LinearLayoutCompat.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
    mScoresLayout = new LinearLayout(context);
    mScoresLayout.setOrientation(LinearLayout.VERTICAL);
    addView(mScoresLayout, new LinearLayoutCompat.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
}
 
开发者ID:jruesga,项目名称:rview,代码行数:15,代码来源:ReviewLabelsView.java


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