下面列出了android.view.ViewGroup#setLayoutParams ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public View getView(int position, View convertView, ViewGroup parent) {
final Preference preference = this.getItem(position);
// Build a PreferenceLayout to compare with known ones that are cacheable.
mTempPreferenceLayout = createPreferenceLayout(preference, mTempPreferenceLayout);
// If it's not one of the cached ones, set the convertView to null so that
// the layout gets re-created by the Preference.
if (Collections.binarySearch(mPreferenceLayouts, mTempPreferenceLayout) < 0 ||
(getItemViewType(position) == getHighlightItemViewType())) {
convertView = null;
}
View result = preference.getView(convertView, parent);
if (position == mHighlightedPosition && mHighlightedDrawable != null) {
ViewGroup wrapper = new FrameLayout(parent.getContext());
wrapper.setLayoutParams(sWrapperLayoutParams);
wrapper.setBackgroundDrawable(mHighlightedDrawable);
wrapper.addView(result);
result = wrapper;
}
return result;
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
addView(LayoutInflater.from(getContext()).inflate(R.layout.holly_view_pager, this, false));
viewPager = (ViewPager) findViewById(R.id.bfp_viewPager);
headerScroll = (HorizontalScrollView) findViewById(R.id.bfp_headerScroll);
headerLayout = (ViewGroup) findViewById(R.id.bfp_headerLayout);
{
ViewGroup.LayoutParams layoutParams = headerLayout.getLayoutParams();
layoutParams.height = this.settings.headerHeightPx;
headerLayout.setLayoutParams(layoutParams);
}
animator = new HollyViewPagerAnimator(this);
}
private void setSize(Bitmap b, ViewGroup v) {
int bW = b.getWidth();
int bH = b.getHeight();
int vW = v.getMeasuredWidth();
int vH = v.getMeasuredHeight();
float scalW = (float) vW / (float) bW;
float scalH = (float) vH / (float) bH;
ViewGroup.LayoutParams params = v.getLayoutParams();
//如果图片小于viewGroup的宽高则把viewgroup设置为图片宽高
// if (bW < vW && bH < vH) {
// params.width = bW;
// params.height = bH;
// v.setLayoutParams(params);
// return;
// }
if (bW >= bH) {
params.width = vW;
params.height = (int) (scalW * bH);
} else {
params.width = (int) (scalH * bW);
params.height = vH;
}
if (params.width > vW) {
float tempScaleW = (float) vW / (float) params.width;
params.width = vW;
params.height = (int) (params.height * tempScaleW);
}
if (params.height > vH) {
float tempScaleH = (float) vH / (float) params.height;
params.height = vH;
params.width = (int) (params.width * tempScaleH);
}
v.setLayoutParams(params);
}
private void configurePageLayout(ViewGroup pageView, int position) {
int coordinatorWidth = getMeasuredWidth();
int reversePosition = getNumOfPages() - 1 - position;
int pageMarginLeft = (coordinatorWidth * reversePosition);
int originalHeight = pageView.getLayoutParams().height;
LayoutParams layoutParams = new LayoutParams(coordinatorWidth, originalHeight);
layoutParams.setMargins(pageMarginLeft, WITHOUT_MARGIN, WITHOUT_MARGIN, WITHOUT_MARGIN);
pageView.setLayoutParams(layoutParams);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRootView = (ViewGroup) inflater.inflate(R.layout.fragment_connect, container, false);
mRootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return mRootView;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ViewGroup.LayoutParams lp = parent.getLayoutParams();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = ScreenUtils.dpToPx(500f, mActivity);
parent.setLayoutParams(lp);
@SuppressLint("ViewHolder") View view = LayoutInflater.from(mContextThemeWrapper).inflate(R.layout.list_item_transactions_2, parent, false);
TransactionViewHolder viewHolder = new TransactionViewHolder(mParams, this, mActivity, view);
viewHolder.bindTransaction(mTransactionList.get(position));
return viewHolder.itemView;
}
/**
* Configure navigation drawer for the persistent mode.
*/
private void configureDrawer() {
if (isPersistentDrawer()) {
mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN);
mDrawer.setScrimColor(Color.TRANSPARENT);
mDrawerToggle.setDrawerIndicatorEnabled(false);
ViewGroup frame = findViewById(R.id.ads_activity_root);
if (frame != null && frame.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) {
ViewGroup.MarginLayoutParams params =
(ViewGroup.MarginLayoutParams) frame.getLayoutParams();
if (DynamicLocaleUtils.isLayoutRtl()) {
params.rightMargin = getResources().getDimensionPixelOffset(
R.dimen.ads_margin_content_start);
} else {
params.leftMargin = getResources().getDimensionPixelOffset(
R.dimen.ads_margin_content_start);
}
frame.setLayoutParams(params);
}
} else {
if (isDrawerLocked()) {
mDrawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
getContentView().post(new Runnable() {
@Override
public void run() {
mDrawer.closeDrawers();
}
});
}
}
}
@Override
public AbsMessageViewHolder onCreateViewHolder(MessagesAdapter adapter, ViewGroup root, Peer peer) {
ViewGroup holder = (ViewGroup) ViewUtils.inflate(id, root);
if (!(holder instanceof BubbleContainer)) {
BubbleContainer rootHolder = new BubbleContainer(root.getContext());
rootHolder.addView(holder, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
holder = rootHolder;
holder.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
return creator.onCreateViewHolder(adapter, holder, peer);
}
public void pop(Options mergeOptions, CommandListener listener) {
if (!canPop()) {
listener.onError("Nothing to pop");
return;
}
peek().mergeOptions(mergeOptions);
Options disappearingOptions = resolveCurrentOptions(presenter.getDefaultOptions());
final ViewController disappearing = stack.pop();
final ViewController appearing = stack.peek();
disappearing.onViewWillDisappear();
appearing.onViewWillAppear();
ViewGroup appearingView = appearing.getView();
if (appearingView.getLayoutParams() == null) {
appearingView.setLayoutParams(matchParentWithBehaviour(new StackBehaviour(this)));
}
if (appearingView.getParent() == null) {
getView().addView(appearingView, 0);
}
presenter.onChildWillAppear(this, appearing, disappearing);
if (disappearingOptions.animations.pop.enabled.isTrueOrUndefined()) {
animator.pop(disappearing.getView(), disappearingOptions.animations.pop, () -> finishPopping(disappearing, listener));
} else {
finishPopping(disappearing, listener);
}
}
/**
* @param view
* @param flowLayout 因为我的flowLayout 用lib库 lib库要在用flowlayout就循环了 坑爹 所以 加了这个参数;传一个flowLayout即可
* @param xParts
* @param yParts
* @return ImageView[] 如果为null 则证明 失败;
*/
public static ImageView[] clipView(ImageView view, ViewGroup flowLayout, int xParts, int yParts) {
ViewGroup parentView = (ViewGroup) view.getParent();
if (parentView == null)
return null;
Bitmap viewBmp = ViewShot.getCacheBitmap(view);
int bmpWidth = viewBmp.getWidth() / xParts;
int bmpHeight = viewBmp.getHeight() / yParts;
flowLayout.setLayoutParams(getLayoutParams(view));
ImageView[] imageViews = new ImageView[xParts * yParts];
int i = 0;
for (int y = 0; y < yParts; y++) {
for (int x = 0; x < xParts; x++) {
imageViews[i] = new ImageView(view.getContext());
//截图的感觉;
imageViews[i].setImageBitmap(
Bitmap.createBitmap(viewBmp,
bmpWidth * x, bmpHeight * y,
bmpWidth, bmpHeight));
flowLayout.addView(imageViews[i]);
i++;
}
}
int childIndex = parentView.indexOfChild(view);
parentView.removeView(view);
parentView.addView(flowLayout, childIndex);
return imageViews;
}
private void initializeMenuline(final ViewGroup item) {
item.setBackgroundColor(mItemBGColor);
if (mStyle.isRoundedTabs()) {
item.setBackground(mStyle.getBgDrawableFor(item, mItemBGColor));
}
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams((int)mMain.getResources().getDimension(R.dimen.action_menu_width), ViewGroup.LayoutParams.WRAP_CONTENT);
lp.setMargins(12,13,12,13);
item.setLayoutParams(lp);
mShortcutActionsList.addView(item);
if (mAnimationDuration>0) {
if (mShortcutActionsList.getChildCount() > mOldNum) {
item.setVisibility(View.GONE);
}
item.setScaleY(.1f);
item.animate()
.scaleY(1f)
.setDuration(mAnimationDuration)
.setStartDelay(mShortcutActionsList.getChildCount() * 10 + 10)
.withStartAction(new Runnable() {
@Override
public void run() {
item.setVisibility(View.VISIBLE);
}
});
}
}
private void addBehaviorAttr(final ViewGroup container) {
final CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) container.getLayoutParams();
layoutParams.setBehavior(new AppBarLayout.ScrollingViewBehavior());
container.setLayoutParams(layoutParams);
}
@Override
public boolean doOnCreate(Bundle bundle) {
super.doOnCreate(bundle);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
LinearLayout __ll = new LinearLayout(this);
__ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup bounceScrollView = new BounceScrollView(this, null);
bounceScrollView.setId(R.id.rootBounceScrollView);
ll.setId(R.id.rootMainLayout);
//invoke_virtual(bounceScrollView,"a",true,500,500,boolean.class,int.class,int.class);
bounceScrollView.setLayoutParams(mmlp);
bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
//invoke_virtual(bounceScrollView,"setNeedHorizontalGesture",true,boolean.class);
LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(this, 48));
RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
int mar = (int) (dip2px(this, 12) + 0.5f);
__lp_l.setMargins(mar, 0, mar, 0);
__lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
__lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
__lp_r.setMargins(mar, 0, mar, 0);
__lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
__lp_r.addRule(RelativeLayout.CENTER_VERTICAL);
ColorStateList hiColor = ColorStateList.valueOf(Color.argb(255, 242, 140, 72));
RelativeLayout _t;
ll.addView(subtitle(this, "QNotified是开源软件,完全免费,无需任何授权/卡密/加群即可使用全部功能,没有卡密或者授权这类的东西,请勿上当受骗!!!"));
ll.addView(subtitle(this, "如果你希望支持作者, 保持更新的动力, 可请使用以下方式捐赠, 完成后手动打开 [我已捐赠] 即可"));
ll.addView(subtitle(this, "免费开发不易, 需要花费很多个人精力, 且回报甚微, 甚至有人盗卖, 感谢理解"));
RelativeLayout iHaveDonated = newListItemSwitchConfig(this, "我已捐赠", null, qn_donated_choice, false);
((CompoundButton) iHaveDonated.findViewById(R_ID_SWITCH)).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
try {
ConfigManager cfg = ConfigManager.getDefaultConfig();
cfg.putBoolean(qn_donated_choice, isChecked);
cfg.save();
if (isChecked) {
showToast(DonateActivity.this, TOAST_TYPE_SUCCESS, "感谢您的支持", Toast.LENGTH_SHORT);
}
} catch (Throwable e) {
log(e);
showToast(DonateActivity.this, TOAST_TYPE_ERROR, "出了点问题:" + e, Toast.LENGTH_SHORT);
}
}
});
ll.addView(iHaveDonated);
ll.addView(subtitle(this, "感谢您的支持!"));
ll.addView(subtitle(this, ""));
ll.addView(subtitle(this, "目前还存在一个较为严重的问题:"));
ll.addView(subtitle(this, " 虽然QNotified是一个完全免费的插件,但仍因有不少人对本软件进行二次贩卖(如:以群发器的名义贩卖),不少人上当受骗"));
ll.addView(subtitle(this, "从用户反馈来看,这种贩卖情况并非个例"));
ll.addView(subtitle(this, "这违背了我的本意: **我希望任何个人都能免费的使用本软件**"));
ll.addView(subtitle(this, "从根本上说,如果任何需要本软件的人都能免费地获取本软件,那么倒卖这种的情况就不会发生"));
ll.addView(subtitle(this, "所以"));
ll.addView(subtitle(this, "每多一个人免费地分发本软件,可能因贩卖上当的人就少一个"));
ll.addView(subtitle(this, "譬如说,可以在各大玩机论坛社区以资源分享的方式分发免费软件(包括但不限于本模块,尽量别设置回复可见)"));
ll.addView(subtitle(this, "当然以上只是其中一种方法"));
ll.addView(subtitle(this, "本软件首发地为 https://github.com/cinit/QNotified (求star/issue/pull request)"));
ll.addView(subtitle(this, "最后,谢谢你的支持"));
ll.addView(subtitle(this, "by"));
if (isNiceUser()) ll.addView(newListItemButton(this, "QQ", "点击私信", "1041703712", clickToChat()));
ll.addView(newListItemButton(this, "Mail", null, "[email protected]", null));
ll.addView(newListItemButton(this, "Telegram", null, "Auride", clickToUrl("https://t.me/Auride")));
ll.addView(subtitle(this, "扶贫方式"));
if (isNiceUser()) ll.addView(newListItemButton(this, "支付宝", null, null, clickToAlipay()));
ll.addView(subtitle(this, "FAQ1:"));
ll.addView(subtitle(this, "Q: 捐赠后能解锁隐藏功能吗?"));
ll.addView(subtitle(this, "A: 不能. 所有功能全部都是可以白嫖的"));
ll.addView(subtitle(this, "FAQ2:"));
ll.addView(subtitle(this, "Q: 我捐赠过,但是QQ数据被清除后没了怎么办"));
ll.addView(subtitle(this, "A: 直接打开 我已捐赠 即可"));
ll.addView(subtitle(this, "FAQ3:"));
ll.addView(subtitle(this, "Q: 已知 我已捐赠 这个Switch开和关没有任何区别,那这个开关意义何在"));
ll.addView(subtitle(this, "A: 和B站上up主的明示投币一个道理"));
ll.addView(subtitle(this, "FAQ4:"));
ll.addView(subtitle(this, "Q: 为什么不加个授权验证,然后收费?"));
ll.addView(subtitle(this, "A: 开源软件搞什么授权验证"));
//bounceScrollView.setFocusable(true);
//bounceScrollView.setFocusableInTouchMode(true);
__ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
this.setContentView(bounceScrollView);
LinearLayout.LayoutParams _lp_fat = new LinearLayout.LayoutParams(MATCH_PARENT, 0);
_lp_fat.weight = 1;
//__ll.addView(bounceScrollView,_lp_fat);
//sdlv.setBackgroundColor(0xFFAA0000)
setTitle("捐赠");
setContentBackgroundDrawable(ResUtils.skin_background);
//TextView rightBtn=(TextView)invoke_virtual(this,"getRightTextView");
//log("Title:"+invoke_virtual(this,"getTextTitle"));
return true;
}
@Override
public boolean doOnCreate(Bundle bundle) {
super.doOnCreate(bundle);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
LinearLayout __ll = new LinearLayout(this);
__ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup bounceScrollView = new BounceScrollView(this, null);
//invoke_virtual(bounceScrollView,"a",true,500,500,boolean.class,int.class,int.class);
bounceScrollView.setLayoutParams(mmlp);
bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
//invoke_virtual(bounceScrollView,"setNeedHorizontalGesture",true,boolean.class);
LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(this, 48));
RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
int mar = (int) (dip2px(this, 12) + 0.5f);
__lp_l.setMargins(mar, 0, mar, 0);
__lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
__lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
__lp_r.setMargins(mar, 0, mar, 0);
__lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
__lp_r.addRule(RelativeLayout.CENTER_VERTICAL);
ColorStateList hiColor = ColorStateList.valueOf(Color.argb(255, 242, 140, 72));
RelativeLayout _t;
ll.addView(subtitle(this, "QNotified"));
ll.addView(subtitle(this, "本模块无毒无害, 免费开源, 旨在\n 1.接手部分停更模块的部分功能\n 2.提供被删好友通知\n 3.移除部分臃肿功能, 增加部分实用功能"));
ll.addView(subtitle(this, "注意: 6.5.5以下版本的QQ已不再受支持"));
ll.addView(subtitle(this, "此模块目前承认的APP发布渠道为 Github 上本项目的 Releases 和 Xposed Installer 里的模块下载 ,也可从https://github.com/cinit/QNotified 获取源码自行编译, 如果您是在其他渠道下载的话请自己注意安全.\n Copyright (C) 2019-2020 [email protected]"));
ll.addView(subtitle(this, "支持的(类)Xposed内核:"));
ll.addView(subtitle(this, "原生Xposed, Epic(太极), SandHook, YAHFA ,BugHook(应用转生), etc"));
ll.addView(subtitle(this, "声明:"));
ll.addView(subtitle(this, "此软件是捐赠软件 个人可以免费使用 请勿以任何方式商用本软件 如果喜欢我的作品请打赏支持我维护和开发! 任何形式或渠道包括预装手机售卖此软件都是非法贩卖, 别上当受骗!欢迎举报贩卖者! ", Color.RED));
ll.addView(subtitle(this, "特别声明:"));
ll.addView(subtitle(this, "QNotified模块属于个人作品! 没有售后! 没有客服! 您可以与我反馈和讨论问题, 但请文明交流尊重彼此!"));
ll.addView(subtitle(this, "免责声明: 一切后果自负(包括但不限于群发导致的冻结封号)", Color.RED));
ll.addView(subtitle(this, "用户协议: The GNU General Public License v3.0"));
ll.addView(subtitle(this, "This program is distributed in the hope that it will be useful, " +
"but WITHOUT ANY WARRANTY; without even the implied warranty of " +
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."));
ll.addView(subtitle(this, "请尊重我的的劳动成果 请勿用于商业用途 严禁盗版贩卖", Color.RED));
ll.addView(subtitle(this, "遇到 免费软件(包括但不限于本软件) 倒卖者请直接举报, 谢谢您的配合!"));
//bounceScrollView.setFocusable(true);
//bounceScrollView.setFocusableInTouchMode(true);
__ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
this.setContentView(bounceScrollView);
LinearLayout.LayoutParams _lp_fat = new LinearLayout.LayoutParams(MATCH_PARENT, 0);
_lp_fat.weight = 1;
//__ll.addView(bounceScrollView,_lp_fat);
setContentBackgroundDrawable(ResUtils.skin_background);
setTitle("关于");
return true;
}
@Override
public boolean doOnCreate(Bundle bundle) {
super.doOnCreate(bundle);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
LinearLayout __ll = new LinearLayout(FakeBatCfgActivity.this);
__ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup bounceScrollView = new BounceScrollView(this, null);
//invoke_virtual(bounceScrollView,"a",true,500,500,boolean.class,int.class,int.class);
bounceScrollView.setLayoutParams(mmlp);
bounceScrollView.setId(R.id.rootBounceScrollView);
ll.setId(R.id.rootMainLayout);
bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
//invoke_virtual(bounceScrollView,"setNeedHorizontalGesture",true,boolean.class);
LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(FakeBatCfgActivity.this, 48));
RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
int mar = (int) (dip2px(FakeBatCfgActivity.this, 12) + 0.5f);
__lp_l.setMargins(mar, 0, mar, 0);
__lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
__lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
__lp_r.setMargins(mar, 0, mar, 0);
__lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
__lp_r.addRule(RelativeLayout.CENTER_VERTICAL);
ll.addView(subtitle(FakeBatCfgActivity.this, "!!! 此功能仅在 QQ>=8.2.6 且在线状态为 我的电量 时生效"));
ll.addView(subtitle(FakeBatCfgActivity.this, "服务器的电量数据有6分钟的延迟属于正常情况"));
ll.addView(subtitle(FakeBatCfgActivity.this, "请不要把电量设置为 0 ,因为 0 会被TX和谐掉"));
FakeBatteryHook bat = FakeBatteryHook.get();
boolean enabled = bat.isEnabled();
LinearLayout _t;
ll.addView(_t = subtitle(FakeBatCfgActivity.this, ""));
tvStatus = (TextView) _t.getChildAt(0);
ll.addView(subtitle(FakeBatCfgActivity.this, "设置自定义电量百分比:"));
int _5dp = dip2px(FakeBatCfgActivity.this, 5);
EditText pct = new EditText(FakeBatCfgActivity.this);
pct.setId(R_ID_PERCENT_VALUE);
pct.setInputType(TYPE_CLASS_NUMBER);
pct.setTextColor(ResUtils.skin_black);
pct.setTextSize(dip2sp(FakeBatCfgActivity.this, 18));
pct.setBackgroundDrawable(null);
pct.setGravity(Gravity.CENTER);
pct.setPadding(_5dp, _5dp / 2, _5dp, _5dp / 2);
pct.setBackgroundDrawable(new HighContrastBorder());
pct.setHint("电量百分比, 取值范围 [1,100]");
pct.setText(bat.getFakeBatteryCapacity() + "");
pct.setSelection(pct.getText().length());
ll.addView(pct, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
CheckBox charging = new CheckBox(FakeBatCfgActivity.this);
charging.setId(R_ID_CHARGING);
charging.setText("正在充电");
charging.setTextSize(17);
charging.setTextColor(ResUtils.skin_black);
charging.setButtonDrawable(ResUtils.getCheckBoxBackground());
charging.setPadding(_5dp, _5dp, _5dp, _5dp);
charging.setChecked(FakeBatteryHook.get().isFakeBatteryCharging());
ll.addView(charging, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 3 * _5dp, _5dp, 2 * _5dp, _5dp));
Button apply = new Button(FakeBatCfgActivity.this);
apply.setId(R_ID_APPLY);
apply.setOnClickListener(this);
ResUtils.applyStyleCommonBtnBlue(apply);
ll.addView(apply, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
Button dis = new Button(FakeBatCfgActivity.this);
dis.setId(R_ID_DISABLE);
dis.setOnClickListener(this);
ResUtils.applyStyleCommonBtnBlue(dis);
dis.setText("停用");
ll.addView(dis, newLinearLayoutParams(MATCH_PARENT, WRAP_CONTENT, 2 * _5dp, _5dp, 2 * _5dp, _5dp));
__ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
setContentView(bounceScrollView);
showStatus();
setContentBackgroundDrawable(ResUtils.skin_background);
setTitle("自定义电量");
return true;
}
@Override
public boolean doOnCreate(Bundle bundle) {
super.doOnCreate(bundle);
LinearLayout ll = new LinearLayout(this);
ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
LinearLayout __ll = new LinearLayout(this);
__ll.setOrientation(LinearLayout.VERTICAL);
ViewGroup bounceScrollView = new BounceScrollView(this, null);
bounceScrollView.setLayoutParams(mmlp);
bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(this, 48));
RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
int mar = (int) (dip2px(this, 12) + 0.5f);
__lp_l.setMargins(mar, 0, mar, 0);
__lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
__lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
__lp_r.setMargins(mar, 0, mar, 0);
__lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
__lp_r.addRule(RelativeLayout.CENTER_VERTICAL);
ll.addView(subtitle(this, "牙膏要一点一点挤, 显卡要一刀一刀切, PPT要一张一张放, 代码要一行一行写, 单个功能预计自出现在commit之日起, 三年内开发完毕"));
ll.addView(newListItemSwitchStub(this, "强制使用默认字体", null, false));
ll.addView(newListItemSwitchStub(this, "点一下赞20次", "仅限回赞界面, 与花Q等效", false));
ll.addView(newListItemSwitchStub(this, "无视QQ电话与语音冲突", "允许在QQ电话时播放语音和短视频", false));
ll.addView(newListItemSwitchStub(this, "QQ电话关麦时解除占用", "再开麦时如麦被其他程序占用可能崩溃", false));
ll.addView(newListItemSwitchStub(this, "屏蔽好友热播", "隐藏动态里的好友热播", false));
ll.addView(newListItemSwitchConfigStub(this, "屏蔽回执消息的通知", null, ConfigItems.qn_mute_talk_back, false));
ll.addView(newListItemButton(this, "小尾巴", "请勿在多个模块同时开启小尾巴", "[无]", clickTheComing()));
ll.addView(newListItemButton(this, "聊天图片自动接收原图", null, "禁用", clickTheComing()));
ll.addView(newListItemButton(this, "强制原图发送聊天图片", null, "禁用", clickTheComing()));
ll.addView(newListItemButton(this, "隐藏联系人", "和自带的\"隐藏会话\"有所不同", "0人", clickTheComing()));
ll.addView(newListItemButton(this, "自定义本地头像", "仅本机生效", "禁用", clickTheComing()));
ll.addView(newListItemButton(this, "高级通知设置", "通知展开, channel等", null, clickTheComing()));
ll.addView(newListItemButton(this, "QQ电话睡眠模式", "仅保持连麦, 暂停消息接收, 减少电量消耗", null, clickTheComing()));
ll.addView(newListItemSwitchStub(this, "禁用QQ公交卡", "如果QQ在后台会干扰NFC的话", false));
ll.addView(newListItemButton(this, "AddFriendReq.sourceID", "自定义加好友来源", "[不改动]", clickTheComing()));
ll.addView(newListItemButton(this, "DelFriendReq.delType", "只能为1或2", "[不改动]", clickTheComing()));
ll.addView(newListItemSwitchStub(this, "隐藏聊天界面右侧滑条", "强迫症专用", false));
__ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
this.setContentView(bounceScrollView);
LinearLayout.LayoutParams _lp_fat = new LinearLayout.LayoutParams(MATCH_PARENT, 0);
_lp_fat.weight = 1;
//__ll.addView(bounceScrollView,_lp_fat);
//sdlv.setBackgroundColor(0xFFAA0000)
setTitle("咕咕咕");
setContentBackgroundDrawable(ResUtils.skin_background);
return true;
}
protected void initViews() {
LayoutInflater layoutInflater = LayoutInflater.from(context);
decorView = (ViewGroup) ((Activity) context).getWindow().getDecorView().findViewById(android.R.id.content);
rootView = (ViewGroup) layoutInflater.inflate(R.layout.layout_alertview, decorView, false);
rootView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
));
// rootView.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View view, MotionEvent motionEvent) {
// if () {
// dismiss();
// }
// return false;
// }
// });
contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
contentContainer.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});
int margin_alert_left_right = 0;
switch (style) {
case ActionSheet:
params.gravity = Gravity.BOTTOM;
margin_alert_left_right = context.getResources().getDimensionPixelSize(R.dimen.margin_actionsheet_left_right);
params.setMargins(margin_alert_left_right, 0, margin_alert_left_right, margin_alert_left_right);
contentContainer.setLayoutParams(params);
gravity = Gravity.BOTTOM;
initActionSheetViews(layoutInflater);
break;
case Alert:
params.gravity = Gravity.CENTER;
margin_alert_left_right = context.getResources().getDimensionPixelSize(R.dimen.margin_alert_left_right);
params.setMargins(margin_alert_left_right, 0, margin_alert_left_right, 0);
contentContainer.setLayoutParams(params);
gravity = Gravity.CENTER;
initAlertViews(layoutInflater);
break;
}
}
/**
* Creates a new view to be used as an ad.
* <p/>
* This method is called when you call {@link MoPubStreamAdPlacer#getAdView}
* and the convertView is null. You must return a valid view.
*
* @param context The context. Useful for creating a view. This is recommended to be an
* Activity. If you have custom themes defined in your Activity, not passing
* in that Activity will result in the default Application theme being used
* when creating the ad view.
* @param parent The parent that the view will eventually be attached to. You might use the
* parent to determine layout parameters, but should return the view without
* attaching it to the parent.
*
* @return A new ad view.
*/
@NonNull @Override public View createAdView(@NonNull Context context,
@Nullable ViewGroup parent) {
mAdView = LayoutInflater.from(context)
.inflate(mViewBinder.layoutId, parent, false);
final View mainImageView = mAdView.findViewById(mViewBinder.mainImageId);
if (mainImageView == null) {
return mAdView;
}
final ViewGroup.LayoutParams mainImageViewLayoutParams = mainImageView.getLayoutParams();
final RelativeLayout.LayoutParams primaryViewLayoutParams =
new RelativeLayout.LayoutParams(mainImageViewLayoutParams.width,
mainImageViewLayoutParams.height);
if (mainImageViewLayoutParams instanceof ViewGroup.MarginLayoutParams) {
final ViewGroup.MarginLayoutParams marginParams =
(ViewGroup.MarginLayoutParams) mainImageViewLayoutParams;
primaryViewLayoutParams.setMargins(marginParams.leftMargin, marginParams.topMargin,
marginParams.rightMargin, marginParams.bottomMargin);
primaryViewLayoutParams.addRule(RelativeLayout.BELOW, mViewBinder.mainImageId);
}
if (mainImageViewLayoutParams instanceof RelativeLayout.LayoutParams) {
final RelativeLayout.LayoutParams mainImageViewRelativeLayoutParams =
(RelativeLayout.LayoutParams) mainImageViewLayoutParams;
final int[] rules = mainImageViewRelativeLayoutParams.getRules();
for (int i = 0; i < rules.length; i++) {
primaryViewLayoutParams.addRule(i, rules[i]);
}
}
mainImageView.setVisibility(View.INVISIBLE);
if (mViewBinder.extras.get(VIEW_BINDER_KEY_PRIMARY_AD_VIEW_LAYOUT) != null) {
final ViewGroup primaryAdLayout =
mAdView.findViewById(mViewBinder.extras.get(VIEW_BINDER_KEY_PRIMARY_AD_VIEW_LAYOUT));
if (primaryAdLayout != null && primaryAdLayout instanceof RelativeLayout) {
primaryAdLayout.setLayoutParams(primaryViewLayoutParams);
}
}
return mAdView;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(resourceId);
try {
ViewGroup root = (ViewGroup) findViewById(R.id.easy_alert_dialog_layout);
if (root != null) {
ViewGroup.LayoutParams params = root.getLayoutParams();
params.width = (int)ScreenUtil.getDialogWidth();
root.setLayoutParams(params);
}
titleView = findViewById(R.id.easy_dialog_title_view);
if (titleView != null) {
setTitleVisible(isTitleVisible);
}
titleBtn = (ImageButton) findViewById(R.id.easy_dialog_title_button);
if (titleBtn != null) {
setTitleBtnVisible(isTitleBtnVisible);
}
titleTV = (TextView) findViewById(R.id.easy_dialog_title_text_view);
if (titleTV != null) {
titleTV.setText(title);
if (NO_TEXT_COLOR != titleTextColor)
titleTV.setTextColor(titleTextColor);
if (NO_TEXT_SIZE != titleTextSize)
titleTV.setTextSize(titleTextSize);
}
messageTV = (TextView) findViewById(R.id.easy_dialog_message_text_view);
if (messageTV != null) {
messageTV.setText(message);
setMessageVisible(isMessageVisble);
if (NO_TEXT_COLOR != msgTextColor)
messageTV.setTextColor(msgTextColor);
if (NO_TEXT_SIZE != msgTextSize)
messageTV.setTextSize(msgTextSize);
}
message2TV = (TextView) findViewById(R.id.easy_dialog_message_2);
if(message2TV != null && !TextUtils.isEmpty(message2)) {
message2TV.setVisibility(View.VISIBLE);
message2TV.setText(message2);
}
positiveBtn = (Button) findViewById(R.id.easy_dialog_positive_btn);
if (isPositiveBtnVisible && positiveBtn != null) {
positiveBtn.setVisibility(View.VISIBLE);
if (NO_TEXT_COLOR != positiveBtnTitleTextColor) {
positiveBtn.setTextColor(positiveBtnTitleTextColor);
}
if (NO_TEXT_SIZE != positiveBtnTitleTextSize) {
positiveBtn.setTextSize(positiveBtnTitleTextSize);
}
positiveBtn.setText(positiveBtnTitle);
positiveBtn.setOnClickListener(positiveBtnListener);
}
negativeBtn = (Button) findViewById(R.id.easy_dialog_negative_btn);
btnDivideView = findViewById(R.id.easy_dialog_btn_divide_view);
if (isNegativeBtnVisible) {
negativeBtn.setVisibility(View.VISIBLE);
btnDivideView.setVisibility(View.VISIBLE);
if (NO_TEXT_COLOR != this.negativeBtnTitleTextColor) {
negativeBtn.setTextColor(negativeBtnTitleTextColor);
}
if (NO_TEXT_SIZE != this.negativeBtnTitleTextSize) {
negativeBtn.setTextSize(negativeBtnTitleTextSize);
}
negativeBtn.setText(negativeBtnTitle);
negativeBtn.setOnClickListener(negativeBtnListener);
}
if (mViewListener != null && mViewListener.size() != 0) {
Iterator iter = mViewListener.entrySet().iterator();
View view = null;
while (iter.hasNext()) {
Map.Entry<Integer, View.OnClickListener> entry = (Map.Entry) iter.next();
view = findViewById(entry.getKey());
if(view != null && entry.getValue() != null) {
view.setOnClickListener(entry.getValue());
}
}
}
} catch (Exception e) {
}
}
private static void swapMainLayoutWithDismissingLayout(ViewGroup viewGroup, Activity activity) {
if (viewGroup == null) {
return;
}
String className = "";
String viewGroupClassName = viewGroup.getClass().getSimpleName();
for (String name : sSupportedClasses) {
if (viewGroupClassName.equals(name)) {
className = name;
}
}
ViewGroup generatedLayout = viewGroup;
switch (className) {
case "LinearLayout":
generatedLayout = new KeyboardDismissingLinearLayout(activity);
break;
case "RelativeLayout":
generatedLayout = new KeyboardDismissingRelativeLayout(activity);
break;
case "CoordinatorLayout":
generatedLayout = new KeyboardDismissingCoordinatorLayout(activity);
break;
case "ConstraintLayout":
generatedLayout = new KeyboardDismissingConstraintLayout(activity);
}
if (className.isEmpty()) {
return;
}
if (viewGroup.getLayoutParams() != null) {
generatedLayout.setLayoutParams(viewGroup.getLayoutParams());
} else {
generatedLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
}
if (generatedLayout instanceof KeyboardDismissingConstraintLayout) {
int widthOfOriginalLayout = ConstraintLayout.LayoutParams.MATCH_PARENT;
int heightOfOriginalLayout = ConstraintLayout.LayoutParams.MATCH_PARENT;
if (viewGroup.getLayoutParams() != null) {
widthOfOriginalLayout = viewGroup.getLayoutParams().width;
heightOfOriginalLayout = viewGroup.getLayoutParams().height;
}
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(widthOfOriginalLayout, heightOfOriginalLayout);
layoutParams.validate();
generatedLayout.setLayoutParams(layoutParams);
}
while (viewGroup.getChildCount() != 0) {
View child = viewGroup.getChildAt(0);
viewGroup.removeViewAt(0);
generatedLayout.addView(child);
}
viewGroup.removeAllViews();
viewGroup.addView(generatedLayout, 0);
}