我使用了这段代码(在库中也一样):
// The following code will reposition the OK button to the left.relativeLayout.LayoutParams lps = new relativeLayout.LayoutParams( VIEwGroup.LayoutParams.WRAP_CONTENT,VIEwGroup.LayoutParams.WRAP_CONTENT);lps.addRule(relativeLayout.AliGN_PARENT_BottOM);lps.addRule(relativeLayout.AliGN_PARENT_left);int margin = ((Number) (getResources().getdisplayMetrics().density * 12)) .intValue();lps.setmargins(margin,margin,margin);VIEw showcasedVIEw = findVIEwByID(R.ID.ib_next);VIEwTarget target = new VIEwTarget(showcasedVIEw);ShowcaseVIEw.ConfigOptions co = new ShowcaseVIEw.ConfigOptions();co.buttonLayoutParams = lps;co.fadeInDuration = 1000;co.fadeOutDuration = 1000;ShowcaseVIEw sv = ShowcaseVIEw.insertShowcaseVIEw(target,this,R.string.showcase_Title,R.string.showcase_details,co);
但它不起作用?任何人都可以告诉问题在哪里?
解决方法 我知道这个问题已经过时了,但万一有人需要一个有效的解决方案:relativeLayout.LayoutParams lps = new relativeLayout.LayoutParams(VIEwGroup.LayoutParams.WRAP_CONTENT,VIEwGroup.LayoutParams.WRAP_CONTENT);// This aligns button to the bottom left sIDe of screenlps.addRule(relativeLayout.AliGN_PARENT_BottOM);lps.addRule(relativeLayout.AliGN_PARENT_left);// Set margins to the button,we add 16dp margins hereint margin = ((Number) (getResources().getdisplayMetrics().density * 16)).intValue();lps.setmargins(margin,margin);VIEwTarget target = new VIEwTarget(R.ID.buttonBlocked,this);sv = new ShowcaseVIEw.Builder(this) .withMaterialShowcase() .setTarget(target) .setContentTitle(R.string.showcase_main_Title) .setContentText(R.string.showcase_main_message) .build();// Set declared button position to ShowcaseVIEwsv.setbuttonposition(lps);
这对我有用,希望它对某人有所帮助.
总结以上是内存溢出为你收集整理的Android ShowCaseView的buttonLayoutParams不起作用全部内容,希望文章能够帮你解决Android ShowCaseView的buttonLayoutParams不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)