Android 项目 UI混乱,Button变大,解决方案

最近公司项目中,脑袋一大随手修改了一下targetSdkVersion,改成了21(原来是19以下)。结果遇到的问题就是Viewpagerindicator的指示器不能正常显示。具体怎么不能正常显示姑且理解为部分UI乱套了就好了。

我看了下4.4系统api的说明,在Build.java类里面

  '''  /**
     * <a href="http://www.it165.net/pro/ydad/" target="_blank" class="keylink">Android</a> 4.4: KitKat, another tasty treat.
     *
     * <p>Applications targeting this or a later release will get these
     * new changes in behavior:</p>
     * <ul>
     * <li> The default result of {android.preference.PreferenceActivity#isValidFragment
     * PreferenceActivity.isValueFragment} becomes false instead of true.</li>
     * <li> In {@link android.webkit.WebView}, apps targeting earlier versions will have
     * JS URLs evaluated directly and any result of the evaluation will not replace
     * the current page content.  Apps targetting KITKAT or later that load a JS URL will
     * have the result of that URL replace the content of the current page</li>
     * <li> {@link android.app.AlarmManager#set AlarmManager.set} becomes interpreted as
     * an inexact value, to give the system more flexibility in scheduling alarms.</li>
     * <li> {@link android.content.Context#getSharedPreferences(String, int)
     * Context.getSharedPreferences} no longer allows a null name.</li>
     * <li> {@link android.widget.RelativeLayout} changes to compute wrapped content
     * margins correctly.</li>
     * <li> {@link android.app.ActionBar}'s window content overlay is allowed to be
     * drawn.</li>
     * <li>The {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
     * permission is now always enforced.</li>
     * <li>Access to package-specific external storage directories belonging
     * to the calling app no longer requires the
     * {@link android.Manifest.permission#READ_EXTERNAL_STORAGE} or
     * {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE}
     * permissions.</li>
     * </ul>
     */
    public static final int KITKAT = 19;

里面有句话说了android.widget.RelativeLayout} changes to compute wrapped content margins correctly,说重新修改了RelativeLayout计算margin的方式。。。。


4.0源码的makeMeasureSpec是这样实现的:

 /**
* Creates a measure specification based on the supplied size and 
*
 * The mode must always be one of the following:
* <ul>
*  <li>{@link android.view.View.MeasureSpec#UNSPECIFIED}</li>
*  <li>{@link android.view.View.MeasureSpec#EXACTLY}</li>
*  <li>{@link android.view.View.MeasureSpec#AT_MOST}</li>
* </ul>
 *
* @param size the size of the measure specification
* @param mode the mode of the measure specification
* @return the measure specification based on size and mode
*/
   public static int makeMeasureSpec(int size, int mode) {
  return size + mode;
  }

Button变大这个问题可以在你的AppThemes里面加上下面这句话解决:

 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:buttonStyle">@android:style/Widget.Button.Small</item>
    </style>
所以说问题就出现在这了!!!!总的来说要是嫌麻烦就改回19以下,不嫌麻烦把写错的方法改一下或用的库就更新一下。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值