本文整理匯總了Java中android.widget.Space類的典型用法代碼示例。如果您正苦於以下問題:Java Space類的具體用法?Java Space怎麽用?Java Space使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Space類屬於android.widget包,在下文中一共展示了Space類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initUI
import android.widget.Space; //導入依賴的package包/類
private void initUI(Context context, int size){
setOrientation(VERTICAL);
setGravity(Gravity.CENTER_HORIZONTAL);
setBackgroundColor(Color.WHITE);
icon = new ImageView(context);
icon.setScaleType(ImageView.ScaleType.CENTER_CROP);
LayoutParams iconLp = new LayoutParams(size, size);
iconLp.topMargin = Style.dp2px(8);
addView(icon, iconLp);
titleTextView = new TextView(context);
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
LayoutParams titleLp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
titleLp.topMargin = Style.dp2px(4.0);
addView(titleTextView, titleLp);
Space space = new Space(context);
LayoutParams spaceLp = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
Style.dp2px(8));
addView(space, spaceLp);
}
示例2: finishLoadingPhotos
import android.widget.Space; //導入依賴的package包/類
private void finishLoadingPhotos()
{
mIntroView.stopWaitAnimation();
LinearLayout container = (LinearLayout) findViewById(R.id.container);
LayoutInflater inflater = getLayoutInflater();
Space spacer = new Space(this);
spacer.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
findViewById(R.id.scroller).getHeight()));
container.addView(spacer);
for (State s : mStates)
{
addState(inflater, container, s);
}
}
示例3: CellViewHolder
import android.widget.Space; //導入依賴的package包/類
public CellViewHolder(View itemView, Picasso picasso, boolean shouldShowAvatarPresence) {
super(itemView);
mUserName = (TextView) itemView.findViewById(R.id.sender);
mTimeGroup = itemView.findViewById(R.id.time_group);
mTimeGroupDay = (TextView) itemView.findViewById(R.id.time_group_day);
mTimeGroupTime = (TextView) itemView.findViewById(R.id.time_group_time);
mClusterSpaceGap = (Space) itemView.findViewById(R.id.cluster_space);
mCell = (ViewGroup) itemView.findViewById(R.id.cell);
mReceipt = (TextView) itemView.findViewById(R.id.receipt);
mAvatar = ((AtlasAvatar) itemView.findViewById(R.id.avatar));
if (mAvatar != null) {
mAvatar.init(picasso);
mAvatar.setShouldShowPresence(shouldShowAvatarPresence);
}
}
示例4: addView
import android.widget.Space; //導入依賴的package包/類
@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
if (LOG_PRIORITY <= Log.VERBOSE) Log.v(LOG_TAG, "addView(View, int, ViewGroup.LayoutParams)");
if (index >= 0 && index % 2 == 0) {
if (LOG_PRIORITY <= Log.WARN) {
Log.w(LOG_TAG, "addView(View, int, ViewGroup.LayoutParams) does nothing since indicated a gap index");
}
return;
} else {
super.addView(child, index, params);
Space gap = generateGap();
gap.setTag(child);
if (index != -1) index++;
float weight = 1;
if (checkLayoutParams(params)) weight = ((LayoutParams) params).gap;
super.addView(gap, index, generateGapLayoutParams(weight));
}
}
示例5: addSpaceToContainer
import android.widget.Space; //導入依賴的package包/類
/**
* Adds empty space view to {@link #mHolder#containerView container} for a
* short {@link #LAYOUT_ANIMATION_TIME}. This uses {@link #mHandler}!
*
* @param height height of space view in pixels.
*/
private void addSpaceToContainer(final int height) {
final Space space = new Space(mHolder.context);
final ViewGroup.LayoutParams lp = new LinearLayout.LayoutParams(0, height);
mHolder.containerView.addView(space, lp);
mHolder.containerOffset++;
// Remove space view after a while.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
mHolder.containerView.removeView(space);
mHolder.containerOffset--;
}
}, LAYOUT_ANIMATION_TIME);
}
示例6: setup
import android.widget.Space; //導入依賴的package包/類
public void setup(Window window,
@IdRes int textButtonId, @IdRes int textSpaceId,
@IdRes int iconButtonId) {
textButton = (Button) window.findViewById(textButtonId);
textSpace = (Space) window.findViewById(textSpaceId);
iconButton = (FloatingActionButton) window.findViewById(iconButtonId);
}
示例7: addSample
import android.widget.Space; //導入依賴的package包/類
private void addSample(CharSequence title, View sample) {
SampleView sampleView = new SampleView(this);
sampleView.bind(title, sample);
mSampleContainer.addView(sampleView);
Space space = new Space(this);
mSampleContainer.addView(space);
space.getLayoutParams().height = getResources().getDimensionPixelSize(R.dimen.sample_padding);
}
示例8: finishLoadingPhotos
import android.widget.Space; //導入依賴的package包/類
private void finishLoadingPhotos() {
mIntroView.stopWaitAnimation();
LinearLayout container = (LinearLayout) findViewById(R.id.container);
LayoutInflater inflater = getLayoutInflater();
Space spacer = new Space(this);
spacer.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
findViewById(R.id.scroller).getHeight()));
container.addView(spacer);
for (State s : mStates) {
addState(inflater, container, s);
}
}
示例9: deleteModuleView
import android.widget.Space; //導入依賴的package包/類
private void deleteModuleView(String module) {
View moduleView = moduleViews.remove(module);
if (moduleView != null) {
int index;
for (index = 0; !moduleView.equals(getChildAt(index)); ++index);
removeView(moduleView);
// Warning: Atrocious hack to place views in the desired place, Part II.
while (index > 0 && getChildAt(--index) instanceof Space) {
removeViewAt(index);
}
}
invalidateAll();
}
示例10: Ui_init
import android.widget.Space; //導入依賴的package包/類
public void Ui_init(View v){
big_view = new BigViewController(v.getContext());
Space space = new Space(v.getContext());
Space space2 = new Space(v.getContext());
space2.setLayoutParams(new GridLayout.LayoutParams(GridLayout.spec(0,0), GridLayout.spec(12,5)));
final GridLayout table = (GridLayout) v.findViewById(R.id.table_layout);
GridLayout lantan = (GridLayout) v.findViewById(R.id.lantan);
GridLayout.LayoutParams bigViewParams = new GridLayout.LayoutParams(GridLayout.spec(0,3), GridLayout.spec(2,10));
bigViewParams.width = x_size*BV_X_SIZE;
bigViewParams.height = y_size*BV_Y_SIZE;
big_view.setLayoutParams(bigViewParams);
for(int i = 0; i < this.container.getSize(); i++) {
ChemElement buf = this.container.getElementByNumber(i + 1);
buf.setSize(x_size - (ELEMENTS_MARGIN_LEFT + ELEMENTS_MARGIN_RIGHT), y_size - (ELEMENTS_MARGIN_TOP + ELEMENTS_MARGIN_BUTTOM));
switch (buf.getElementNumber()){
case 2:
table.addView(space);
table.addView(big_view);
table.addView(space2);
break;
}
if(buf.isLantanoid())
{
lantan.addView(buf);
}
else {
table.addView(buf);
}
buf.setOnClickListener(this);
buf.setOnLongClickListener(this);
GridLayout.LayoutParams params = (GridLayout.LayoutParams) buf.getLayoutParams();
params.setMargins(ELEMENTS_MARGIN_LEFT,ELEMENTS_MARGIN_TOP,ELEMENTS_MARGIN_RIGHT,ELEMENTS_MARGIN_BUTTOM);
buf.setLayoutParams(params);
}
temp = (SeekBar) v.findViewById(R.id.temp);
temp.setOnSeekBarChangeListener(new TempSeekBarListener(temp));
temp.setProgress(NORMAL_TEMPERATURE_K);
temp_tx = (TextView) v.findViewById(R.id.temp_tx);
}
示例11: CollaborativeDishLayout
import android.widget.Space; //導入依賴的package包/類
public CollaborativeDishLayout(Context context) {
super(context);
setOrientation(HORIZONTAL);
setGravity(Gravity.CENTER);
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
Space space1 = new Space(context);
LinearLayout.LayoutParams spaceLayout = new LinearLayout.LayoutParams(40, ViewGroup.LayoutParams.MATCH_PARENT);
addView(space1, spaceLayout);
dishName = new EditText(context);
dishName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
dishName.setTextColor(getResources().getColor(R.color.black));
dishName.setHintTextColor(getResources().getColor(R.color.gray));
dishName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
dishName.setHint("Nombre");
dishName.setWidth(10);
LinearLayout.LayoutParams nomPlatLayout = new LinearLayout.LayoutParams(350, ViewGroup.LayoutParams.WRAP_CONTENT);
addView(dishName, nomPlatLayout);
Space space5 = new Space(context);
LinearLayout.LayoutParams space5Layout = new LinearLayout.LayoutParams(15, ViewGroup.LayoutParams.MATCH_PARENT);
addView(space5, space5Layout);
close = new ImageButton(context);
close.setBackgroundColor(getResources().getColor(R.color.white));
close.setImageResource(R.drawable.cross);
close.setScaleType(ImageView.ScaleType.FIT_XY);
close.setScaleX(0.5f);
close.setScaleY(0.5f);
close.setId((int) Math.random());
LinearLayout.LayoutParams closeLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CollaborativeDishLayout.this.setVisibility(GONE);
}
});
addView(close, closeLayout);
Space space6 = new Space(context);
LinearLayout.LayoutParams space6Layout = new LinearLayout.LayoutParams(15, ViewGroup.LayoutParams.MATCH_PARENT);
addView(space6, space6Layout);
}
示例12: PaymentDishLayout
import android.widget.Space; //導入依賴的package包/類
public PaymentDishLayout(Context context) {
super(context);
setOrientation(VERTICAL);
setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
int margin12 = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, getResources().getDisplayMetrics());
//H1
final LinearLayout h1 = new LinearLayout(context);
h1.setOrientation(HORIZONTAL);
dishName = new EditText(context);
dishName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
dishName.setTextColor(getResources().getColor(R.color.black));
dishName.setHint("Nombre");
dishName.setHintTextColor(getResources().getColor(R.color.gray));
dishName.setTextSize(20);
dishName.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
LinearLayout.LayoutParams nomPlatLayout = new LinearLayout.LayoutParams(400, ViewGroup.LayoutParams.WRAP_CONTENT);
nomPlatLayout.setMargins(margin12, 0, 0, 0);
h1.addView(dishName, nomPlatLayout);
Space space5 = new Space(context);
LinearLayout.LayoutParams space5Layout = new LinearLayout.LayoutParams(8, ViewGroup.LayoutParams.MATCH_PARENT);
h1.addView(space5, space5Layout);
priceDish = new EditText(context);
priceDish.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
priceDish.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
priceDish.setTextColor(getResources().getColor(R.color.black));
priceDish.setHint("Precio");
priceDish.setHintTextColor(getResources().getColor(R.color.gray));
priceDish.setTextSize(20);
LinearLayout.LayoutParams priceDishLayout = new LinearLayout.LayoutParams(160, ViewGroup.LayoutParams.WRAP_CONTENT);
h1.addView(priceDish, priceDishLayout);
Space space6 = new Space(context);
LinearLayout.LayoutParams space6Layout = new LinearLayout.LayoutParams(2, ViewGroup.LayoutParams.WRAP_CONTENT);
h1.addView(space6, space6Layout);
eur = new TextView(context);
eur.setText("€");
eur.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
eur.setTextColor(getResources().getColor(R.color.gray));
LinearLayout.LayoutParams eurLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
h1.addView(eur, eurLayout);
Space space7 = new Space(context);
LinearLayout.LayoutParams space7Layout = new LinearLayout.LayoutParams(20, ViewGroup.LayoutParams.WRAP_CONTENT);
h1.addView(space7, space7Layout);
close = new ImageButton(context);
close.setBackgroundColor(getResources().getColor(R.color.white));
close.setImageResource(R.drawable.cross);
close.setScaleType(ImageView.ScaleType.FIT_XY);
close.setScaleX(0.5f);
close.setScaleY(0.5f);
close.setId((int) Math.random());
LinearLayout.LayoutParams closeLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PaymentDishLayout.this.setVisibility(GONE);
}
});
h1.addView(close, closeLayout);
LinearLayout.LayoutParams h1Layout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
this.addView(h1, h1Layout);
}
示例13: changeMode
import android.widget.Space; //導入依賴的package包/類
public void changeMode(Mode newMode) {
if (mode == Mode.LICENSE)
return;
mode = newMode;
if (releasedTimedThread != null)
releasedTimedThread.forciblyStop();
TextView headerText = (TextView) findViewById(R.id.headerText);
TextView subText = (TextView) findViewById(R.id.subText);
Space space1 = (Space) findViewById(R.id.space1);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar);
ImageButton closeButton = (ImageButton) findViewById(R.id.closeButton);
TextView middleText = (TextView) findViewById(R.id.middleText);
Space space2 = (Space) findViewById(R.id.space2);
ImageButton mainButton = (ImageButton) findViewById(R.id.mainButton);
TextView bottomText = (TextView) findViewById(R.id.bottomText);
Space space3 = (Space) findViewById(R.id.space3);
int fingerId = getResources().getIdentifier("@drawable/finger_icon", null, getPackageName());
int shakeId = getResources().getIdentifier("@drawable/shake_icon", null, getPackageName());
switch (mode) {
case MAIN:
headerText.setText("Stroll Safe");
subText.setText("Keeping You Safe on Late Night Strolls");
space1.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
progressBar.setVisibility(View.GONE);
closeButton.setVisibility(View.GONE);
middleText.setVisibility(View.GONE);
space2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 0f));
mainButton.setImageDrawable(getResources().getDrawable(fingerId));
bottomText.setText("Press and Hold to Arm");
bottomText.setVisibility(View.VISIBLE);
space3.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 0f));
break;
case RELEASE:
headerText.setText("Release Mode");
subText.setText("Release Thumb to Contact Police");
space1.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
progressBar.setVisibility(View.GONE);
closeButton.setVisibility(View.GONE);
middleText.setVisibility(View.GONE);
space2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 0f));
mainButton.setImageDrawable(getResources().getDrawable(shakeId));
bottomText.setText("Slide Thumb and Release to Enter Shake Mode");
bottomText.setVisibility(View.VISIBLE);
space3.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 3f));
break;
case SHAKE:
headerText.setText("Shake Mode");
subText.setText("Shake Phone to Contact Police");
space1.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
progressBar.setVisibility(View.GONE);
closeButton.setVisibility(View.VISIBLE);
middleText.setText("Press and Hold to Exit the App");
middleText.setVisibility(View.VISIBLE);
space2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
mainButton.setImageDrawable(getResources().getDrawable(fingerId));
bottomText.setText("Press and Hold to Enter Release Mode");
bottomText.setVisibility(View.VISIBLE);
space3.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 0f));
break;
case THUMB:
headerText.setText("Thumb Released");
subText.setText("Press and Hold Button to Cancel");
space1.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
progressBar.setVisibility(View.VISIBLE);
closeButton.setVisibility(View.GONE);
middleText.setVisibility(View.VISIBLE);
space2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f));
mainButton.setImageDrawable(getResources().getDrawable(fingerId));
bottomText.setVisibility(View.GONE);
space3.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 0f));
HandleThumbReleased();
break;
}
}
示例14: loadCategoryCards
import android.widget.Space; //導入依賴的package包/類
public void loadCategoryCards() {
//save the data for future uses
MainActivity.categoryList = name;
MainActivity.categoryIDs = id;
//hide the progress bar
pb.setVisibility(View.GONE);
//create a layout inflater
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//iterate over reach category
for (int i = 0; i < count; i++) {
//create a card view for each category
CardView cv = (CardView) inflater.inflate(R.layout.card_layout, ll, false);
final int finalI = i;
//associate a listener to it
cv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//pass the category ID as bundle data: this will allow us to easily retrieve the ID when the card
//is tapped and use it
Bundle bundle = new Bundle();
bundle.putInt("category_id", id[finalI]);
//associate the loading of a list fragment to the tap
Fragment newFragment = new ListFragment();
newFragment.setArguments(bundle);
getFragmentManager()
.beginTransaction()
.replace(R.id.frame, newFragment)
.commit();
}
});
//add the card view to the layout
ll.addView(cv);
//add a space between the cards
if (i != count-1) {
Space space = (Space) inflater.inflate(R.layout.spaaaaaaaaace_im_in_space, ll, false);
ll.addView(space);
}
//create a reference to the view items
ImageView img = (ImageView) cv.findViewById(R.id.imageView2);
TextView tv = (TextView) cv.findViewById(R.id.textView3);
//fill them
img.setImageBitmap(slideshow[i]);
tv.setText(name[i]);
}
//show the cards
ll.setVisibility(View.VISIBLE);
}
示例15: loadProductCards
import android.widget.Space; //導入依賴的package包/類
public void loadProductCards() {
//hide the progress bar
pb2.setVisibility(View.GONE);
//create a layout inflater
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//iterate over reach product
for (int i = 0; i < count2; i++) {
//create a card view for each product
CardView cv = (CardView) inflater.inflate(R.layout.card_layout, ll2, false);
final int finalI = i;
//associate a listener to it
cv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//pass the product ID as bundle data: this will allow us to easily retrieve the ID when the card
//is tapped and use it
Bundle bundle = new Bundle();
bundle.putInt("id", id2[finalI]);
//associate the loading of a list fragment to the tap
Fragment newFragment = new ListFragment();
newFragment.setArguments(bundle);
getFragmentManager()
.beginTransaction()
.replace(R.id.frame, newFragment)
.commit();
}
});
//add the card view to the layout
ll2.addView(cv);
//add a space between the cards
if (i != count2-1) {
Space space = (Space) inflater.inflate(R.layout.spaaaaaaaaace_im_in_space, ll2, false);
ll2.addView(space);
}
//create a reference to the view items
ImageView img = (ImageView) cv.findViewById(R.id.imageView2);
TextView tv = (TextView) cv.findViewById(R.id.textView3);
//fill them
img.setImageBitmap(slideshow2[i]);
tv.setText(name2[i]);
}
//show the cards
ll2.setVisibility(View.VISIBLE);
}