當前位置: 首頁>>代碼示例>>Java>>正文


Java ConstraintLayout類代碼示例

本文整理匯總了Java中android.support.constraint.ConstraintLayout的典型用法代碼示例。如果您正苦於以下問題:Java ConstraintLayout類的具體用法?Java ConstraintLayout怎麽用?Java ConstraintLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConstraintLayout類屬於android.support.constraint包,在下文中一共展示了ConstraintLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addPlayer

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void addPlayer(View view) {
    EditText newNameText = (EditText) findViewById(R.id.newNameText);
    String newName = newNameText.getText().toString();
    newNameText.setText("");

    if (newName.length() > 0 && playerNum < maxNum) {
        shiftPlayersDown();

        TextView playerName = (TextView) findViewById(playerTextIds.get(0));
        playerName.setText(newName);

        ConstraintLayout playerLayout = (ConstraintLayout) findViewById(playerLayoutIds.get(playerNum));
        playerLayout.setVisibility(View.VISIBLE);

        playerNum++;
    }
}
 
開發者ID:agware,項目名稱:UpAndDown,代碼行數:18,代碼來源:AddPlayersActivity.java

示例2: removePlayer

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void removePlayer(View view) {
    int playerIndex = -1;
    for(int i = 0; i < playerNum; i++) {
        if (view.getId() == playerButtonIds.get(i)) {
            playerIndex = i;
            break;
        }
    }

    if (playerIndex >= 0) {
        shiftPlayersUp(playerIndex);

        playerNum--;
        ConstraintLayout playerLayout = (ConstraintLayout) findViewById(playerLayoutIds.get(playerNum));
        playerLayout.setVisibility(View.INVISIBLE);
    }
}
 
開發者ID:agware,項目名稱:UpAndDown,代碼行數:18,代碼來源:AddPlayersActivity.java

示例3: initViews

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
/**
 * This method will create the view object from XLM to Java and instanciate objects. Used when the user reboots it's device
 *
 */
private void initViews() {
    //init graphical element
    txtViewGlucose=(TextView)view.findViewById(R.id.txtView_GlucoseValue);
    txtViewPulse=(TextView)view.findViewById(R.id.txtView_pulseValue);
    txtViewSystol=(TextView)view.findViewById(R.id.txtView_systolValue);
    txtViewDiastol=(TextView)view.findViewById(R.id.txtView_DiastolValue);
    txtViewSteps=(TextView)view.findViewById(R.id.txtView_stepValue);
    txtViewWeight=(TextView)view.findViewById(R.id.txtView_weightValue);

    //create the bar object
    barPulse=(ConstraintLayout)view.findViewById(R.id.bar_pulse);
    barGlucose=(ConstraintLayout)view.findViewById(R.id.bar_glucose);
    barSystol=(ConstraintLayout)view.findViewById(R.id.bar_sys);
    barDiastol=(ConstraintLayout)view.findViewById(R.id.bar_dias);
    barStep=(ConstraintLayout)view.findViewById(R.id.bar_step);
    barWeight=(ConstraintLayout)view.findViewById(R.id.bar_weight);

    imgGlucose=(ImageButton) view.findViewById(R.id.img_severity_glucose);
    imgPulse=(ImageButton) view.findViewById(R.id.img_severity_pulse);
    imgPressure=(ImageButton)view.findViewById(R.id.img_severity_pressure);
    imgStep=(ImageButton)view.findViewById(R.id.img_severity_step);
    imgWeight=(ImageButton)view.findViewById(R.id.img_severity_weight);
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:28,代碼來源:FragmentHome.java

示例4: onDoubleTap

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public boolean onDoubleTap(MotionEvent event) {
    Log.d(DEBUG_TAG, "onDoubleTap: " + event.toString());
    ConstraintLayout bimg = (ConstraintLayout) findViewById(R.id.layout);
    String background = String.valueOf(bimg.getTag());
    if (background.equals("img")) {
        bimg.setBackgroundResource(R.drawable.wallp);
        bimg.setTag("wallp");
    } else {
        if (background.equals("wallp")) {
            bimg.setBackgroundResource(R.drawable.fond);
            bimg.setTag("fond");
        } else {
            if (background.equals("fond")) {
                bimg.setBackgroundResource(R.drawable.img);
                bimg.setTag("img");
            }
        }
    }
    return true;
}
 
開發者ID:Jayant11,項目名稱:LockScreen-Oreo,代碼行數:22,代碼來源:LockedScreen.java

示例5: onCreate

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.constraintset_example_main);

    mRootLayout = (ConstraintLayout) findViewById(R.id.activity_constraintset_example);
    // Note that this can also be achieved by calling
    // `mConstraintSetNormal.load(this, R.layout.constraintset_example_main);`
    // Since we already have an inflated ConstraintLayout in `mRootLayout`, clone() is
    // faster and considered the best practice.
    mConstraintSetNormal.clone(mRootLayout);
    // Load the constraints from the layout where ImageView is enlarged.
    mConstraintSetBig.load(this, R.layout.constraintset_example_big);

    if (savedInstanceState != null) {
        boolean previous = savedInstanceState.getBoolean(SHOW_BIG_IMAGE);
        if (previous != mShowBigImage) {
            mShowBigImage = previous;
            applyConfig();
        }
    }
}
 
開發者ID:googlesamples,項目名稱:android-ConstraintLayoutExamples,代碼行數:23,代碼來源:ConstraintSetExampleActivity.java

示例6: reloadImages

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
private void reloadImages( final ConstraintLayout fab, final DatabaseReference ref, final String uid ) {
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            ref.addValueEventListener(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot snapshot) {
                    clearPicList();

                    updatePicList( snapshot, uid );

                    gridAdapter.notifyDataSetChanged();
                    gridView.invalidateViews();
                    ref.removeEventListener(this);
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    ref.removeEventListener(this);
                }
            });
        }
    });
}
 
開發者ID:chrisqz95,項目名稱:couch-potatoes,代碼行數:25,代碼來源:PictureGridActivity.java

示例7: DataViewHolder

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
DataViewHolder(final View itemView) {
    super(itemView);
    textView = (TextView) itemView.findViewById(tv);
    imageView = (ImageView) itemView.findViewById(R.id.iv);
    packageInfo = (TextView) itemView.findViewById(R.id.packageName);

    share = (Button) itemView.findViewById(R.id.shareApk);
    uninstall = (Button) itemView.findViewById(R.id.uninstallApk);
    extract = (Button) itemView.findViewById(R.id.extractApk);

    expandableView = (ConstraintLayout) itemView.findViewById(R.id.expandableView);

    share.setOnClickListener(this);
    uninstall.setOnClickListener(this);
    extract.setOnClickListener(this);

}
 
開發者ID:HitRoxxx,項目名稱:FloatingNew,代碼行數:18,代碼來源:RecyclerViewAdapterSelectedApp.java

示例8: setContentView

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
private void setContentView() {
    int _padding = NumberUtil.get_px(getContext(), 15);
    setPadding(_padding, _padding, _padding, _padding);
    inflate(getContext(), R.layout.widget_sdcard_percent, this);

    _line = (ConstraintLayout) findViewById(R.id.block_percent);
    _text_system = (TextView) findViewById(R.id.textView_count_system);
    _text_blank = (TextView) findViewById(R.id.textView_count_blank);
    _text_file = (TextView) findViewById(R.id.textView_count_file);
    _text_rubbish = (TextView) findViewById(R.id.textView_count_rubbish);

    for (int _temp_i = 0; _temp_i < _line.getChildCount() && _line.getChildAt(_temp_i).getId() == -1; _temp_i++) {
        _line.getChildAt(_temp_i).setId(_temp_i);
    }
    _set_line.clone(_line);
}
 
開發者ID:bonepeople,項目名稱:SDCardCleaner,代碼行數:17,代碼來源:SDCardPercent.java

示例9: bind

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public void bind(final Item item) {
    mTextLabel.setText(item.getLabel());
    ConstraintLayout.LayoutParams layoutParamsTextLabel = (ConstraintLayout.LayoutParams) mTextLabel.getLayoutParams();
    if (item.getPercent() > LABEL_POSITION_CHANGE_PERCENT) {
        // move label above guideline
        layoutParamsTextLabel.bottomToTop = mGuidelineTop.getId();
        layoutParamsTextLabel.topToTop = -1;
        layoutParamsTextLabel.bottomMargin = mLabelMargin;
        layoutParamsTextLabel.topMargin = 0;

    } else {
        // move label below guideline
        layoutParamsTextLabel.topToTop = mGuidelineTop.getId();
        layoutParamsTextLabel.bottomToTop = -1;
        layoutParamsTextLabel.bottomMargin = 0;
        layoutParamsTextLabel.topMargin = mLabelMargin;
    }
    mTextLabel.setLayoutParams(layoutParamsTextLabel);

    ConstraintLayout.LayoutParams layoutParamsGuideline = (ConstraintLayout.LayoutParams) mGuidelineTop.getLayoutParams();
    layoutParamsGuideline.guidePercent = item.getPercent();
    mGuidelineTop.setLayoutParams(layoutParamsGuideline);

}
 
開發者ID:DroidsOnRoids,項目名稱:constraint-layout-charts,代碼行數:25,代碼來源:ChartsViewHolder.java

示例10: ViewHolderItem

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public ViewHolderItem(View itemView) {
            super(itemView);

            itemView.setOnClickListener(this);

//            itemDescription = (TextView) itemView.findViewById(R.id.itemDescription);
            itemName = (TextView) itemView.findViewById(R.id.itemName);
            itemImage = (ImageView) itemView.findViewById(R.id.itemImage);
            priceRange = (TextView) itemView.findViewById(R.id.price_range);
            priceAverage = (TextView) itemView.findViewById(R.id.price_average);
            shopCount = (TextView) itemView.findViewById(R.id.shop_count);
            itemsListItem = (ConstraintLayout) itemView.findViewById(R.id.items_list_item);

            itemRating = (TextView) itemView.findViewById(R.id.item_rating);
            ratingCount = (TextView) itemView.findViewById(R.id.rating_count);

            itemsListItem.setOnClickListener(this);
            itemImage.setOnClickListener(this);
        }
 
開發者ID:SumeetMoray,項目名稱:Nearby-Shops-End-User-Android-app,代碼行數:20,代碼來源:AdapterNewCarts.java

示例11: ViewHolder

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
public ViewHolder(View itemView) {
            super(itemView);

            itemView.setOnClickListener(this);

//            itemDescription = (TextView) itemView.findViewById(R.id.itemDescription);
            itemName = (TextView) itemView.findViewById(R.id.itemName);
            itemImage = (ImageView) itemView.findViewById(R.id.itemImage);
            priceRange = (TextView) itemView.findViewById(R.id.price_range);
            priceAverage = (TextView) itemView.findViewById(R.id.price_average);
            shopCount = (TextView) itemView.findViewById(R.id.shop_count);
            itemsListItem = (ConstraintLayout) itemView.findViewById(R.id.items_list_item);

            itemRating = (TextView) itemView.findViewById(R.id.item_rating);
            ratingCount = (TextView) itemView.findViewById(R.id.rating_count);

            itemsListItem.setOnClickListener(this);
            itemImage.setOnClickListener(this);
        }
 
開發者ID:SumeetMoray,項目名稱:Nearby-Shops-End-User-Android-app,代碼行數:20,代碼來源:AdapterItemHorizontalScreen.java

示例12: onCreateViewHolder

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    ViewHolder viewHolder = null;
    Context context = parent.getContext();
    switch (viewType) {
        case TYPE_TOPIC:
            viewHolder = TopicViewHolder.makeHolder(parent, mContentListener, mNodeListener, mAvatarListener);
            break;
        case TYPE_COMMENT:
            final CommentView view = new CommentView(context);

            view.setLayoutParams(
                    new ConstraintLayout.LayoutParams(
                            ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.WRAP_CONTENT));
            viewHolder = new CommentViewHolder(view, mCommentListener);
    }

    return viewHolder;
}
 
開發者ID:CzBiX,項目名稱:v2ex-android,代碼行數:21,代碼來源:CommentAdapter.java

示例13: onResume

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public void onResume() {
    super.onResume();
    if (getUserVisibleHint()) {
        if (getView() != null) {
            swipeRefreshLayout = getView().findViewById(R.id.swipe_refresh_layout);
        }
    }
    if (swipeRefreshLayout != null) {
        swipeRefreshLayout.setOnRefreshListener(this);
    }
    AppBarLayout appBar = getActivity().findViewById(R.id.appbar);
    if (appBar != null) {
        Guideline guideTopInfo = getView().findViewById(R.id.guideline);
        ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) guideTopInfo.getLayoutParams();
        params.guidePercent = .45f;
        guideTopInfo.setLayoutParams(params);
    }
    refreshHandler.post(refreshRunnable);
}
 
開發者ID:alvinhkh,項目名稱:buseta,代碼行數:21,代碼來源:LwbStopListFragment.java

示例14: onCreateView

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater,
                         ViewGroup container, Bundle savedInstanceState) {
    // The last two arguments ensure LayoutParams are inflated
    // properly.

    View rootView = inflater.inflate(R.layout.fragment_greetings, container, false);
    ok = (BRButton) rootView.findViewById(R.id.ok);
    mainLayout = (ConstraintLayout) rootView.findViewById(R.id.signal_layout);
    background = (RelativeLayout) rootView.findViewById(R.id.layout);

    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();
        }
    });
    return rootView;
}
 
開發者ID:breadwallet,項目名稱:breadwallet-android,代碼行數:20,代碼來源:FragmentGreetings.java

示例15: bind

import android.support.constraint.ConstraintLayout; //導入依賴的package包/類
@Override
public void bind(ConstraintLayout view)
{
    ButterKnife.bind(this, view);
    tvReleaseName.setText(releaseName);
    tvDatePosted.setText("Listed: " + dateFormatter.formatIsoDate(datePosted));
    lytListing.setOnClickListener(onClickListener);
}
 
開發者ID:jbmlaird,項目名稱:DiscogsBrowser,代碼行數:9,代碼來源:ListingModel.java


注:本文中的android.support.constraint.ConstraintLayout類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。