您的位置:首页 > 产品设计 > UI/UE

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

2016-04-25 11:41 302 查看
最近公司项目中,脑袋一大随手修改了一下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以下,不嫌麻烦把写错的方法改一下或用的库就更新一下。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android targetSdk