展会信息港展会大全

OSC android app LayoutParams改进
来源:互联网   发布日期:2015-10-13 14:57:13   浏览:2620次  

导读:OSC android app LayoutParams改进android.view.ViewGroup.LayoutParamspublic static final int FILL_PARENTSince: API Level 1Special value for the height or width requested by a Vie......

OSC android app LayoutParams改进

android.view.ViewGroup.LayoutParams

public static final int FILL_PARENT

Since: API Level 1

Special value for the height or width requested by a View. FILL_PARENT means that the view wants to be as big as its parent, minus the parent's padding, if any. This value is deprecated starting in API Level 8 and replaced by MATCH_PARENT.

Constant Value: -1 (0xffffffff)

////////////////////////////////////////////////////

private void applyTo(View target) {

LayoutParams lp = target.getLayoutParams();

ViewParent parent = target.getParent();

FrameLayout container = new FrameLayout(context);

if (target instanceof TabWidget) {

// set target to the relevant tab child container

target = ((TabWidget) target).getChildTabViewAt(targetTabIndex);

this.target = target;

((ViewGroup) target).addView(container,

new LayoutParams(LayoutParams. MATCH_PARENT, LayoutParams.MATCH_PARENT));

//new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

最好是根据版本来Build.VERSION.SDK_INT;

请参考:

As described in the android documentation, the SDK level (integer) the phone is running is available in:

android.os.Build.VERSION.SDK_INT;

The enum corresponding to this int is in the android.os.Build.VERSION_CODES class.

Code example:

int currentapiVersion = android.os.Build.VERSION.SDK_INT; if (currentapiVersion >= android.os.Build.VERSION_CODES.FROYO){// Do something for froyo and above versions } else{// do something for phones running an SDK before froyo }

Edit: This SDK_INT is available since Donut (android 1.6 / API4) so make sure your application is not retro-compatible with Cupcake (android 1.5 / API3) when you use it or your application will crash (thanks to Programmer Bruce for the precision).

Corresponding android documentation:

http://developer.android.com/reference/android/os/Build.VERSION.html#SDK_INT

http://developer.android.com/reference/android/os/Build.VERSION_CODES.html

赞助本站

人工智能实验室

相关热词: OSC LayoutParams

AiLab云推荐
推荐内容
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港