本文整理汇总了Java中android.widget.FrameLayout.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java FrameLayout.setPadding方法的具体用法?Java FrameLayout.setPadding怎么用?Java FrameLayout.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.FrameLayout
的用法示例。
在下文中一共展示了FrameLayout.setPadding方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import android.widget.FrameLayout; //导入方法依赖的package包/类
public static void show(Context context, int color, CharSequence string, int duration) {
if(context == null) return;
DisplayMetrics dm = context.getResources().getDisplayMetrics();
float density = dm.density;
Toast toast = new Toast(context);
toast.setDuration(duration);
toast.setGravity(Gravity.TOP, 0, (int) (48 * density));
FrameLayout frame = new FrameLayout(context);
frame.setPadding(0, 0, 0, 0);
int width = dm.widthPixels;
FrameLayout.LayoutParams params =
new FrameLayout.LayoutParams(width, FrameLayout.LayoutParams.WRAP_CONTENT);
TextView text = new TextView(context);
text.setMinimumHeight((int) (28 * density));
text.setGravity(Gravity.CENTER);
text.setTextColor(Color.WHITE);
text.setTextSize(14);
frame.addView(text, params);
toast.setView(frame);
text.setBackgroundColor(color);
text.setText(string);
toast.show();
}
示例2: makeColorPresetButton
import android.widget.FrameLayout; //导入方法依赖的package包/类
private void makeColorPresetButton(int color) {
FrameLayout outframe = new FrameLayout(getContext());
outframe.setBackgroundColor(Color.BLACK);
outframe.setPadding(6,6,6,6);
FrameLayout frame = new FrameLayout(getContext());
//frame.setBackgroundColor(Color.BLACK);
frame.setBackgroundResource(R.drawable.transparentgrid);
TextView c = new TextView(getContext());
c.setText(" ");
c.setTextSize(22);
c.setBackgroundColor(color);
// if (color==Color.TRANSPARENT) {
// c.setBackgroundResource(R.drawable.transparentgrid);
// }
c.setTag(color);
c.setClickable(true);
c.setOnClickListener(setColorListener);
frame.addView(c);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setMargins(24, 16, 24, 16);
outframe.setPadding(6,6,6,6);
outframe.addView(frame);
colorPresets.addView(outframe, lp);
}
示例3: onCreate
import android.widget.FrameLayout; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState)
{
ThemeHue.setTheme(WebViewActivity.this);
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_star_webview);
Intent intent = getIntent();
//noinspection ConstantConditions
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarHue.setActionBarColorToSharedPrefsValue(WebViewActivity.this);
if (intent.getAction().equals(Intent.ACTION_VIEW))
{
mURL = intent.getStringExtra("url");
}
FrameLayout parent = findViewById(R.id.webview_parent);
parent.setPadding(0, 0, 0, 0);
final WebView webView = findViewById(R.id.stars_view);
CustomWebView customWebView = new CustomWebView(this, parent, webView, true);
customWebView.loadUrl(mURL);
}
示例4: onInflateView
import android.widget.FrameLayout; //导入方法依赖的package包/类
@NonNull
@Override
public final View onInflateView(@NonNull final LayoutInflater inflater,
@Nullable final ViewGroup parent, @NonNull final Tab item,
final int viewType, @NonNull final Void... params) {
View view = encapsulatedAdapter.onInflateView(inflater, parent, item, viewType, params);
FrameLayout container = new FrameLayout(tabSwitcher.getContext());
container.setPadding(tabSwitcher.getPaddingLeft(), 0, tabSwitcher.getPaddingRight(),
tabSwitcher.getPaddingBottom());
container.setLayoutParams(
new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT));
container.addView(view);
return container;
}
示例5: setupCustomContent
import android.widget.FrameLayout; //导入方法依赖的package包/类
private void setupCustomContent(ViewGroup customPanel) {
View customView;
boolean hasCustomView = false;
if (this.mView != null) {
customView = this.mView;
} else if (this.mViewLayoutResId != 0) {
customView = LayoutInflater.from(this.mContext).inflate(this.mViewLayoutResId, customPanel, false);
} else {
customView = null;
}
if (customView != null) {
hasCustomView = true;
}
if (!(hasCustomView && canTextInput(customView))) {
this.mWindow.setFlags(131072, 131072);
}
if (hasCustomView) {
FrameLayout custom = (FrameLayout) this.mWindow.findViewById(R.id.custom);
custom.addView(customView, new LayoutParams(-1, -1));
if (this.mViewSpacingSpecified) {
custom.setPadding(this.mViewSpacingLeft, this.mViewSpacingTop, this.mViewSpacingRight, this.mViewSpacingBottom);
}
if (this.mListView != null) {
((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0.0f;
return;
}
return;
}
customPanel.setVisibility(8);
}
示例6: setupCustomContent
import android.widget.FrameLayout; //导入方法依赖的package包/类
private void setupCustomContent(ViewGroup customPanel) {
final View customView;
if (mView != null) {
customView = mView;
} else if (mViewLayoutResId != 0) {
final LayoutInflater inflater = LayoutInflater.from(mContext);
customView = inflater.inflate(mViewLayoutResId, customPanel, false);
} else {
customView = null;
}
if (customView != null && mViewRoot == null) {
if (mViewRootId != 0) {
mViewRoot = customView.findViewById(mViewRootId);
if (mViewRoot == null) {
throw new NullPointerException("Unable to find root view for the supplied id "
+ mViewRootId + ".");
}
}
}
final boolean hasCustomView = customView != null;
if (!hasCustomView || !canTextInput(customView)) {
mWindow.setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
if (hasCustomView) {
final FrameLayout custom = (FrameLayout) mWindow.findViewById(R.id.custom);
custom.addView(customView, new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
if (mViewSpacingSpecified) {
custom.setPadding(
mViewSpacingLeft, mViewSpacingTop, mViewSpacingRight, mViewSpacingBottom);
}
if (mListView != null) {
((LinearLayout.LayoutParams) customPanel.getLayoutParams()).weight = 0;
}
} else {
customPanel.setVisibility(View.GONE);
}
}
示例7: updateCourseViews
import android.widget.FrameLayout; //导入方法依赖的package包/类
/**
* 更新课表View
*/
public void updateCourseViews() {
for (final SScheduleViewModelInterface data : courseDataList) {
FrameLayout courseBackView = new FrameLayout(getContext());
FrameLayout.LayoutParams courseBackViewFLP = new FrameLayout.LayoutParams(notFirstEveryColumnsWidth,
notFirstEveryRowHeight * data.getSpan());
courseBackViewFLP.setMargins((data.getDay() - 1) * notFirstEveryColumnsWidth, (data.getJieci() - 1) * notFirstEveryRowHeight, 0, 0);
courseBackView.setLayoutParams(courseBackViewFLP);
courseBackView.setPadding(twoW, twoW, twoW, twoW);
TextView couseInfoTV=mAdapter.getCourseView(data);
// TextView couseInfoTV = new TextView(getContext());
// couseInfoTV.setText(data.getCourseName() + "\n" + data.getClassRoom());
// couseInfoTV.setTextColor(Color.WHITE);
// couseInfoTV.setGravity(Gravity.CENTER);
// couseInfoTV.setPadding(oneW, oneW, oneW, oneW);
// couseInfoTV.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10);
// couseInfoTV.setEllipsize(TextUtils.TruncateAt.END);
// couseInfoTV.setLines(7);
// 设置背景颜色
// int bg = new Random().nextInt(SScheduleTheme.COURSE_BG.length - 1);
// couseInfoTV.setBackgroundResource(SScheduleTheme.COURSE_BG[bg]);
// if (data.getBackColor() != 0) {
// GradientDrawable myGrad = (GradientDrawable) couseInfoTV.getBackground();
// myGrad.setColor(data.getBackColor());
// }
courseBackViewFLP = new FrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT);
couseInfoTV.setLayoutParams(courseBackViewFLP);
couseInfoTV.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
callBack.onCourseItemClick(data);
}
});
courseBackView.addView(couseInfoTV);
myCacheViews.add(courseBackView);
contentView.addView(courseBackView);
}
}
示例8: insetKeyboardView
import android.widget.FrameLayout; //导入方法依赖的package包/类
private static void insetKeyboardView(View decorView, FrameLayout keyboardWrapper) {
final Rect rect = new Rect();
decorView.getWindowVisibleDisplayFrame(rect);
final int paddingBottom = decorView.getHeight() - rect.bottom;
keyboardWrapper.setPadding(0, 0, 0, paddingBottom);
}