當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。