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


Java CardView.LayoutParams方法代码示例

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


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

示例1: SetNewContents

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
private void SetNewContents(int key) {
    if (!Changes(key).equals("null")) {
        CardView.LayoutParams param = new CardView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT);
        CardView card = new CardView(this);
        if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("DARK_THEME_KEY", false))
            card.setCardBackgroundColor(ContextCompat.getColor(this, R.color.DarkcolorPrimary));
        card.setCardElevation(5);
        card.setLayoutParams(param);
        card.setPadding(ConvertTopx(15), ConvertTopx(15), ConvertTopx(15), ConvertTopx(15));
        card.setUseCompatPadding(true);
        TextView changes = new TextView(this);
        changes.setGravity(Gravity.CENTER);
        changes.setPadding(ConvertTopx(5), ConvertTopx(5), ConvertTopx(5), ConvertTopx(5));
        changes.setText(Changes(key));
        changes.setTypeface(Typeface.MONOSPACE);
        if (firebaseRemoteConfig.getBoolean("mark_red") && key == 0)
            changes.setTextColor(Color.RED);
        card.addView(changes);
        layout.addView(card);
    }
    bar.setVisibility(View.GONE);
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:24,代码来源:ChangeLogActivity.java

示例2: showAlertToast

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
/**
 * Show alert toast view
 *
 * @param context    context
 * @param title      title
 * @param drawableId drawable Id
 * @param duration   duration
 */
public static void showAlertToast(Context context, String title, @DrawableRes int drawableId, int duration) {
    Toast toast = makeText(context.getApplicationContext(), title, duration);
    toast.setGravity(Gravity.CENTER, 0, 0);//the setting position of
    View view = LayoutInflater.from(context).inflate(R.layout.layout_alert_toast, null);
    LinearLayout llContent = (LinearLayout) view.findViewById(R.id.ll_content);
    ImageView alertIcon = (ImageView) view.findViewById(R.id.iv_alert_icon);
    TextView alertTitle = (TextView) view.findViewById(R.id.tv_alert_title);
    if (drawableId != 0) {
        alertIcon.setVisibility(View.VISIBLE);
        alertIcon.setImageResource(drawableId);
    } else {
        alertIcon.setVisibility(View.GONE);
    }
    if (!TextUtils.isEmpty(title)) {
        alertTitle.setText(title);
    }
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    int screenWidth = wm.getDefaultDisplay().getWidth();
    int width = (int) (screenWidth / 1.5f);
    CardView.LayoutParams lp = (CardView.LayoutParams) llContent.getLayoutParams();
    lp.width = width;
    llContent.setLayoutParams(lp);
    llContent.requestLayout();
    toast.setView(view);//Set appearance
    toast.show();
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:35,代码来源:ToastUtils.java

示例3: initZoomRegionView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
/**
 * Init the ZoomRegionView for navigate into image when user zoom in
 */
private void initZoomRegionView() {
    if (mZoomRegionView == null) {

        Bitmap init = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
        mContentBitmap = init.copy(Bitmap.Config.ARGB_8888, true);
        init.recycle();
        mContentCanvas = new Canvas(mContentBitmap);

        FrameLayout.LayoutParams layoutParams = new LayoutParams(getWidth() / 4, getHeight() / 4,
                Gravity.TOP | Gravity.END);
        layoutParams.setMargins(12, 12, 12, 12);
        mZoomRegionCardView = new CardView(getContext());
        mZoomRegionCardView.setLayoutParams(layoutParams);
        mZoomRegionCardView.setPreventCornerOverlap(true);
        mZoomRegionCardView.setRadius(0f);
        mZoomRegionCardView.setUseCompatPadding(true);
        mZoomRegionCardView.setVisibility(View.INVISIBLE);

        CardView.LayoutParams childLayoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        mZoomRegionView = new ZoomRegionView(getContext());
        mZoomRegionView.setLayoutParams(childLayoutParams);
        mZoomRegionView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        mZoomRegionView.setOnZoomRegionListener(new ZoomRegionView.OnZoomRegionListener() {
            @Override
            public void onZoomRegionMoved(Rect newRect) {
                mFromZoomRegion = true;
                mZoomCenterX = newRect.centerX() * 4;
                mZoomCenterY = newRect.centerY() * 4;

                invalidate();
            }
        });

        mZoomRegionCardView.addView(mZoomRegionView);
        addView(mZoomRegionCardView);
    }
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:42,代码来源:DrawView.java

示例4: onCreateView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    int index = getArguments().getInt("INDEX");

    View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
    CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
    gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
    for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
        for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
            TextView textView = new TextView(getContext());
            textView.setGravity(Gravity.CENTER);
            textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLength()));
            textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
            textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
                    PreferenceManager.getDefaultSharedPreferences(getContext()).
                            getBoolean("EXTRA_SMALL_FONT", false)));
            textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(textView, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);


    // Inflate the layout for this fragment
    return v;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:45,代码来源:ViewMatrixFragment.java

示例5: onCreateView

import android.support.v7.widget.CardView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    final int index = getArguments().getInt("INDEX");

    View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
    CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
    gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
    for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
        for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
            final TextView textView = new TextView(getContext());
            textView.setGravity(Gravity.CENTER);
            textView.setTag(i * 10 + j);
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
                    final ProgressDialog progressDialog = new ProgressDialog(getContext());
                    progressDialog.setIndeterminate(false);
                    progressDialog.setMessage(getString(R.string.Calculating));
                    progressDialog.setProgress(ProgressDialog.STYLE_SPINNER);
                    progressDialog.setTitle(getString(R.string.Calculating));
                    progressDialog.show();
                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            float res = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetMinorDeterminant(((int) textView.getTag()) / 10, ((int) textView.getTag()) % 10);
                            Message message = new Message();
                            Bundle bundle = new Bundle();
                            bundle.putInt("REX", ((int) textView.getTag()) / 10);
                            bundle.putInt("REY", ((int) textView.getTag()) % 10);
                            bundle.putFloat("VALUE", res);
                            message.setData(bundle);
                            progressDialog.dismiss();
                            handler.sendMessage(message);
                        }
                    };
                    Thread thread = new Thread(runnable);
                    thread.start();
                }
            });
            textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLenght()));
            textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
            textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
                    PreferenceManager.getDefaultSharedPreferences(getContext()).
                            getBoolean("EXTRA_SMALL_FONT", false)));
            textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(textView, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);

    // Inflate the layout for this fragment
    return v;

}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:74,代码来源:MinorChooserFragment.java

示例6: onCreateView

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

    CardView cardView = (CardView) V.findViewById(R.id.EditMatrixCard);

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
    String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
    String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");

    cardView.setCardElevation(Integer.parseInt(string));
    cardView.setCardBackgroundColor(Color.parseColor(string2));

    CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);

    int index = getArguments().getInt("INDEX");
    Matrix m = ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index);

    GridLayout gridLayout = new GridLayout(getContext());
    gridLayout.setRowCount(m.GetRow());
    gridLayout.setColumnCount(m.GetCol());
    for (int i = 0; i < m.GetRow(); i++) {
        for (int j = 0; j < m.GetCol(); j++) {
            EditText editText = new EditText(getContext());
            editText.setId(i * 10 + j);
            editText.setGravity(Gravity.CENTER);
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("DECIMAL_USE", true)) {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else {
                editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                        | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(getLength())});
            if (!PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("SMART_FIT_KEY", false)) {
                editText.setWidth(ConvertTopx(62));
                editText.setTextSize(SizeReturner(3, 3, PreferenceManager.getDefaultSharedPreferences(getContext()).
                        getBoolean("EXTRA_SMALL_FONT", false)));
            } else {
                editText.setWidth(ConvertTopx(CalculatedWidth(m.GetCol())));
                editText.setTextSize(SizeReturner(m.GetRow(), m.GetCol(),
                        PreferenceManager.getDefaultSharedPreferences(getContext()).
                                getBoolean("EXTRA_SMALL_FONT", false)));
            }
            editText.setText(SafeSubString(GetText(m.GetElementof(i, j)), getLength()));
            editText.setSingleLine();
            GridLayout.Spec Row = GridLayout.spec(i, 1);
            GridLayout.Spec Col = GridLayout.spec(j, 1);
            GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
            gridLayout.addView(editText, params);
        }
    }
    gridLayout.setLayoutParams(params1);
    cardView.addView(gridLayout);
    RootView = V;
    return V;
}
 
开发者ID:coder3101,项目名称:Matrix-Calculator-for-Android,代码行数:60,代码来源:EditFragment.java


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