List of usage examples for android.widget GridLayout UNDEFINED
int UNDEFINED
To view the source code for android.widget GridLayout UNDEFINED.
Click Source Link
From source file:io.palaima.debugdrawer.DebugWidgetsFrame.java
@NonNull private GridLayout.LayoutParams getSpanColParams(GridLayout gl) { // http://bbs.csdn.net/topics/391853628 // ?????//w w w .ja v a 2 s . com GridLayout.Spec row = GridLayout.spec(GridLayout.UNDEFINED); // ????? GridLayout.Spec col = GridLayout.spec(GridLayout.UNDEFINED, gl.getColumnCount()); GridLayout.LayoutParams params = new GridLayout.LayoutParams(row, col); params.width = GridLayout.LayoutParams.MATCH_PARENT; return params; }
From source file:com.sonymobile.androidapp.gridcomputing.fragments.ReportChartFragment.java
private void setLegends() { if (mChart.getData().getDataSets().size() > 1) { final Resources resources = ApplicationData.getAppContext().getResources(); final float density = getResources().getDisplayMetrics().density; final float legendWidth = resources.getDimension(R.dimen.chart_legend_width) / density; final float legendHeight = resources.getDimension(R.dimen.chart_legend_height) / density; final float legendMargin = resources.getDimension(R.dimen.chart_legend_margin) / density; final float legendCorner = resources.getDimension(R.dimen.chart_legend_corner) / density; for (ILineDataSet lineDataSet : mChart.getData().getDataSets()) { final CheckBox checkBox = new CheckBox(mLegendLayout.getContext()); checkBox.setChecked(true);// w w w .ja va 2 s . c o m checkBox.setText(lineDataSet.getLabel()); checkBox.setTag(lineDataSet); checkBox.setOnCheckedChangeListener(mLegendCheckedChangeListener); GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setColor(lineDataSet.getColor()); drawable.setSize((int) legendWidth, (int) legendHeight); drawable.setCornerRadius(legendCorner); checkBox.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null); checkBox.setCompoundDrawablePadding((int) legendMargin); final GridLayout.Spec titleTxtSpecColumn = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.Spec titleRowSpec = GridLayout.spec(GridLayout.UNDEFINED); final GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams(titleRowSpec, titleTxtSpecColumn); layoutParams.setMargins((int) legendWidth, 0, (int) legendWidth, 0); mLegendLayout.addView(checkBox, layoutParams); } } }
From source file:com.gelakinetic.mtgfam.fragments.LifeCounterFragment.java
/** * Updates the display mode based on the current value of mDisplayMode. This updates the GridLayout's parameters * and draws the player's views in the fragment. It also shows and hides buttons and views relating to * commander mode./* w ww.ja v a 2 s. c o m*/ */ public void changeDisplayMode(boolean shouldDefaultLives) { /* update the preference */ PreferenceAdapter.setDisplayMode(getContext(), String.valueOf(mDisplayMode)); mGridLayout.removeAllViews(); if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { switch (mDisplayMode) { case DISPLAY_NORMAL: mGridLayout.setOrientation(GridLayout.HORIZONTAL); mGridLayout.setColumnCount(1); mGridLayout.setRowCount(GridLayout.UNDEFINED); break; case DISPLAY_COMPACT: mGridLayout.setOrientation(GridLayout.HORIZONTAL); mGridLayout.setColumnCount(2); mGridLayout.setRowCount(GridLayout.UNDEFINED); break; case DISPLAY_COMMANDER: mGridLayout.setOrientation(GridLayout.HORIZONTAL); mGridLayout.setColumnCount(2); mGridLayout.setRowCount(GridLayout.UNDEFINED); break; } } else { switch (mDisplayMode) { case DISPLAY_NORMAL: mGridLayout.setOrientation(GridLayout.HORIZONTAL); mGridLayout.setColumnCount(GridLayout.UNDEFINED); mGridLayout.setRowCount(1); break; case DISPLAY_COMPACT: mGridLayout.setOrientation(GridLayout.HORIZONTAL); mGridLayout.setColumnCount(GridLayout.UNDEFINED); mGridLayout.setRowCount(1); break; case DISPLAY_COMMANDER: mGridLayout.setOrientation(GridLayout.VERTICAL); mGridLayout.setColumnCount(GridLayout.UNDEFINED); if (mListSizeHeight != -1) { float height = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, getActivity().getResources().getDisplayMetrics()); mGridLayout.setRowCount((int) (mListSizeHeight / height)); } else { mGridLayout.setRowCount(GridLayout.UNDEFINED); } break; } } boolean areLivesDefault = true; for (LcPlayer player : mPlayers) { /* Only reset a player's default life / life if that player is unaltered and doesn't have a noticeably * custom default life */ if (!(player.mLifeHistory.size() == 0 && player.mPoisonHistory.size() == 0 && player.mLife == player.mDefaultLifeTotal && (player.mDefaultLifeTotal == DEFAULT_LIFE || player.mDefaultLifeTotal == DEFAULT_LIFE_COMMANDER))) { areLivesDefault = false; } } if (areLivesDefault && shouldDefaultLives) { for (LcPlayer player : mPlayers) { player.mDefaultLifeTotal = getDefaultLife(); player.mLife = player.mDefaultLifeTotal; } } for (LcPlayer player : mPlayers) { /* Draw the player's view */ addPlayerView(player); } if (mDisplayMode == DISPLAY_COMMANDER) { mCommanderButton.setVisibility(View.VISIBLE); mCommanderPlayerView.setVisibility(View.VISIBLE); mCommanderPlayerView.removeAllViews(); if (mPlayers.size() > 0 && null != mPlayers.get(0).mView) { mCommanderPlayerView.addView(mPlayers.get(0).mView); mPlayers.get(0).setSize(mListSizeWidth, mListSizeHeight, mDisplayMode, getActivity().getResources() .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT); } } else { mCommanderPlayerView.setVisibility(View.GONE); mCommanderButton.setVisibility(View.GONE); if (mStatDisplaying == STAT_COMMANDER) { setStatDisplaying(STAT_LIFE); } } }