android.widget.LinearLayout.LayoutParams#MATCH_PARENT源码实例Demo

下面列出了android.widget.LinearLayout.LayoutParams#MATCH_PARENT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: WhereYouGo   文件: CustomDialog.java
public static void setContent(Activity activity, View view, int margins, boolean fillHeight,
                              boolean dialog) {
    // set width to correct values if dialog is shown
    if (dialog) {
        UtilsGUI.setWindowDialogCorrectWidth(activity.getWindow());
    }
    LayoutParams lp =
            new LayoutParams(LayoutParams.MATCH_PARENT, fillHeight ? LayoutParams.MATCH_PARENT
                    : LayoutParams.WRAP_CONTENT);
    if (margins > 0)
        lp.setMargins(margins, activity.getResources().getDimensionPixelSize(R.dimen.shadow_height)
                + margins, margins, margins);
    LinearLayout llCon = (LinearLayout) activity.findViewById(R.id.linear_layout_content);
    llCon.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            fillHeight ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT));
    addViewToContent(llCon, lp, view);
}
 
源代码2 项目: Field-Book   文件: CollectActivity.java
private void showSummary() {
    LayoutInflater inflater = this.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_summary, null);
    TextView summaryText = layout.findViewById(R.id.field_name);
    summaryText.setText(traitBox.createSummaryText(rangeBox.getPlotID()));

    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppAlertDialog);
    builder.setTitle(R.string.preferences_appearance_toolbar_customize_summary)
            .setCancelable(true)
            .setView(layout);

    builder.setNegativeButton(getString(R.string.dialog_close), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int i) {
            dialog.dismiss();
        }
    });

    final AlertDialog summaryDialog = builder.create();
    summaryDialog.show();
    DialogUtils.styleDialogs(summaryDialog);

    android.view.WindowManager.LayoutParams params2 = summaryDialog.getWindow().getAttributes();
    params2.width = LayoutParams.MATCH_PARENT;
    summaryDialog.getWindow().setAttributes(params2);
}
 
源代码3 项目: WeCenterMobile-Android   文件: EditPage.java
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LinearLayout.LayoutParams lpMain = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpMain.weight = 1;
	int dp_4 = dipToPx(getContext(), 4);
	lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
	llMainBody.setLayoutParams(lpMain);

	LinearLayout llContent = new LinearLayout(getContext());
	LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// 文字输入区域
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(reqData.get("text")));
	etContent.addTextChangedListener(this);
	LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

	llContent.addView(getThumbView());
	llMainBody.addView(getBodyBottom());

	return llMainBody;
}
 
源代码4 项目: Huochexing12306   文件: EditPage.java
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LinearLayout.LayoutParams lpMain = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpMain.weight = 1;
	int dp_4 = dipToPx(getContext(), 4);
	lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
	llMainBody.setLayoutParams(lpMain);

	LinearLayout llContent = new LinearLayout(getContext());
	LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// 文字输入区域
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(reqData.get("text")));
	etContent.addTextChangedListener(this);
	LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

	llContent.addView(getThumbView());
	llMainBody.addView(getBodyBottom());

	return llMainBody;
}
 
源代码5 项目: Huochexing12306   文件: EditPage.java
private LinearLayout getPlatformList() {
	LinearLayout llToolBar = new LinearLayout(getContext());
	LinearLayout.LayoutParams lpTb = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llToolBar.setLayoutParams(lpTb);

	TextView tvShareTo = new TextView(getContext());
	int resId = getStringRes(activity, "share_to");
	if (resId > 0) {
		tvShareTo.setText(resId);
	}
	tvShareTo.setTextColor(0xffcfcfcf);
	tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
	int dp_9 = dipToPx(getContext(), 9);
	LinearLayout.LayoutParams lpShareTo = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpShareTo.gravity = Gravity.CENTER_VERTICAL;
	lpShareTo.setMargins(dp_9, 0, 0, 0);
	tvShareTo.setLayoutParams(lpShareTo);
	llToolBar.addView(tvShareTo);

	HorizontalScrollView sv = new HorizontalScrollView(getContext());
	sv.setHorizontalScrollBarEnabled(false);
	sv.setHorizontalFadingEdgeEnabled(false);
	LinearLayout.LayoutParams lpSv = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
	sv.setLayoutParams(lpSv);
	llToolBar.addView(sv);

	llPlat = new LinearLayout(getContext());
	llPlat.setLayoutParams(new HorizontalScrollView.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
	sv.addView(llPlat);

	return llToolBar;
}
 
源代码6 项目: PHONK   文件: PRow.java
public PRow(Context c, LinearLayout cardLl, int n) {
    this.n = n;
    float t = 100f;
    float tt = t / n;

    ll = new LinearLayout(c);
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.setWeightSum(t);
    cardLl.addView(ll);

    lParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, tt);
}
 
源代码7 项目: XMPPSample_Studio   文件: ActivityChatScreen.java
/**
 * change height of emoticons keyboard according to height of actual
 * keyboard
 *
 * @param height minimum height by which we can make sure actual keyboard is
 *               open or not
 */
private void changeKeyboardHeight(int height) {

    if (height > 100) {
        keyboardHeight = height;
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LayoutParams.MATCH_PARENT, keyboardHeight);
        emoticonsCover.setLayoutParams(params);
    }

}
 
private void doLayout() {
  LinearLayout.LayoutParams playerParams =
      (LinearLayout.LayoutParams) playerView.getLayoutParams();
  if (fullscreen) {
    // When in fullscreen, the visibility of all other views than the player should be set to
    // GONE and the player should be laid out across the whole screen.
    playerParams.width = LayoutParams.MATCH_PARENT;
    playerParams.height = LayoutParams.MATCH_PARENT;

    otherViews.setVisibility(View.GONE);
  } else {
    // This layout is up to you - this is just a simple example (vertically stacked boxes in
    // portrait, horizontally stacked in landscape).
    otherViews.setVisibility(View.VISIBLE);
    ViewGroup.LayoutParams otherViewsParams = otherViews.getLayoutParams();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
      playerParams.width = otherViewsParams.width = 0;
      playerParams.height = WRAP_CONTENT;
      otherViewsParams.height = MATCH_PARENT;
      playerParams.weight = 1;
      baseLayout.setOrientation(LinearLayout.HORIZONTAL);
    } else {
      playerParams.width = otherViewsParams.width = MATCH_PARENT;
      playerParams.height = WRAP_CONTENT;
      playerParams.weight = 0;
      otherViewsParams.height = 0;
      baseLayout.setOrientation(LinearLayout.VERTICAL);
    }
    setControlsEnabled();
  }
}
 
源代码9 项目: Field-Book   文件: FieldEditorActivity.java
private void importDialog(String[] columns) {
    LayoutInflater inflater = this.getLayoutInflater();
    View layout = inflater.inflate(R.layout.dialog_import, null);

    unique = layout.findViewById(R.id.uniqueSpin);
    primary = layout.findViewById(R.id.primarySpin);
    secondary = layout.findViewById(R.id.secondarySpin);

    setSpinner(unique, columns, "ImportUniqueName");
    setSpinner(primary, columns, "ImportFirstName");
    setSpinner(secondary, columns, "ImportSecondName");

    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppAlertDialog);
    builder.setTitle(R.string.import_dialog_title_fields)
            .setCancelable(true)
            .setView(layout);

    builder.setPositiveButton(getString(R.string.dialog_import), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            if (checkImportColumnNames()) {
                mHandler.post(importRunnable);
            }
        }
    });

    importFieldDialog = builder.create();
    importFieldDialog.show();
    DialogUtils.styleDialogs(importFieldDialog);

    android.view.WindowManager.LayoutParams params2 = importFieldDialog.getWindow().getAttributes();
    params2.width = LayoutParams.MATCH_PARENT;
    importFieldDialog.getWindow().setAttributes(params2);
}
 
源代码10 项目: secureit   文件: EmptyFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {    	
	
    if ((savedInstanceState != null) && savedInstanceState.containsKey(CONTENT)) {
        mContent = savedInstanceState.getString(CONTENT);
    }
	
    TextView text = new TextView(getActivity());
    text.setGravity(Gravity.CENTER);
    text.setText(mContent);
    text.setTextSize(20 * getResources().getDisplayMetrics().density);

    RelativeLayout layout = new RelativeLayout(getActivity());
    layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    layout.setGravity(Gravity.CENTER);
    
    RelativeLayout alert = new RelativeLayout(getActivity());
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.leftMargin = 20;
    params.rightMargin = 20;
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    alert.setLayoutParams(params);
    alert.setBackgroundResource(R.drawable.red_back);
    alert.setPadding(30, 0, 30, 0);
    alert.addView(text);
    layout.addView(alert);
  
    return layout;
}
 
源代码11 项目: ShareSDKShareDifMsgDemo-Android   文件: EditPage.java
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LinearLayout.LayoutParams lpMain = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpMain.weight = 1;
	int dp_4 = dipToPx(getContext(), 4);
	lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
	llMainBody.setLayoutParams(lpMain);

	LinearLayout llContent = new LinearLayout(getContext());
	LinearLayout.LayoutParams lpContent = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// 文字输入区域
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(reqData.get("text")));
	etContent.addTextChangedListener(this);
	LinearLayout.LayoutParams lpEt = new LinearLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

	llContent.addView(getThumbView());
	llMainBody.addView(getBodyBottom());

	return llMainBody;
}
 
源代码12 项目: ShareSDKShareDifMsgDemo-Android   文件: EditPage.java
/** 显示平台列表 */
public void afterPlatformListGot() {
	String name = String.valueOf(reqData.get("platform"));
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_24 = dipToPx(getContext(), 24);
	LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_24, dp_24);
	final int dp_9 = dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LinearLayout.LayoutParams(dp_24, dp_24));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		if (name != null && name.equals(platformList[i].getName())) {
			views[i].setVisibility(View.INVISIBLE);
			selection = i;

			// 编辑分享内容的统计
			ShareSDK.logDemoEvent(3, platformList[i]);
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
			return false;
		}
	});
}
 
源代码13 项目: LoveTalkClient   文件: BlogAdapter.java
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
	// TODO Auto-generated method stub
	AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	RelativeLayout ll = new RelativeLayout(mContext);
	ll.setLayoutParams(lp);
	ll.setGravity(Gravity.CENTER);

	RelativeLayout.LayoutParams lpblogTime = new RelativeLayout.LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpblogTime.setMargins(250, 10, 0, 0);
	final TextView blogTime = getTextView();
	blogTime.setLayoutParams(lpblogTime);
	blogTime.setTextColor(Color.RED);
	blogTime.setText(listTime.get(position).toString());
	blogTime.setTextSize(14);
	blogTime.setPadding(0, 0, 0, 0);

	RelativeLayout.LayoutParams lpblogContent = new RelativeLayout.LayoutParams(
			600, LayoutParams.WRAP_CONTENT);
	lpblogContent.setMargins(0, 70, 0, 0);
	final TextView blogContent = getTextView();
	blogContent.setLayoutParams(lpblogContent);
	blogContent.setTextColor(Color.GRAY);
	blogContent.setText(listBlog.get(position).toString());
	blogContent.setTextSize(14);
	blogContent.setPadding(0, 0, 0, 0);

	ll.addView(blogTime);
	ll.addView(blogContent);

	ll.setOnClickListener(new OnClickListener() {

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			blogContent.setTextColor(Color.BLACK);
		}
	});

	return ll;
}
 
源代码14 项目: Huochexing12306   文件: EditPage.java
/** 显示平台列表 */
public void afterPlatformListGot() {
	String name = String.valueOf(reqData.get("platform"));
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_24 = dipToPx(getContext(), 24);
	LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_24, dp_24);
	final int dp_9 = dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LinearLayout.LayoutParams(dp_24, dp_24));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		if (name != null && name.equals(platformList[i].getName())) {
			views[i].setVisibility(View.INVISIBLE);
			selection = i;

			// 编辑分享内容的统计
			ShareSDK.logDemoEvent(3, platformList[i]);
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
			return false;
		}
	});
}
 
public void onCreate() {
	LinearLayout llPage = new LinearLayout(getContext());
	llPage.setBackgroundColor(0xfff5f5f5);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	// 标题栏
	llTitle = new TitleLayout(getContext());
	int resId = getBitmapRes(getContext(), "title_back");
	if (resId > 0) {
		llTitle.setBackgroundResource(resId);
	}
	llTitle.getBtnBack().setOnClickListener(this);
	resId = getStringRes(getContext(), "multi_share");
	if (resId > 0) {
		llTitle.getTvTitle().setText(resId);
	}
	llTitle.getBtnRight().setVisibility(View.VISIBLE);
	resId = getStringRes(getContext(), "finish");
	if (resId > 0) {
		llTitle.getBtnRight().setText(resId);
	}
	llTitle.getBtnRight().setOnClickListener(this);
	llTitle.setLayoutParams(new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	llPage.addView(llTitle);

	FrameLayout flPage = new FrameLayout(getContext());
	LinearLayout.LayoutParams lpFl = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpFl.weight = 1;
	flPage.setLayoutParams(lpFl);
	llPage.addView(flPage);

	// 关注(或朋友)列表
	PullToRefreshView followList = new PullToRefreshView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);
	adapter = new FollowAdapter(followList);
	adapter.setPlatform(platform);
	followList.setAdapter(adapter);
	adapter.getListView().setOnItemClickListener(this);

	ImageView ivShadow = new ImageView(getContext());
	resId = getBitmapRes(getContext(), "title_shadow");
	if (resId > 0) {
		ivShadow.setBackgroundResource(resId);
	}
	FrameLayout.LayoutParams lpSd = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	ivShadow.setLayoutParams(lpSd);
	flPage.addView(ivShadow);

	// 请求数据
	followList.performPulling(true);
}
 
/** display platform list */
public void afterPlatformListGot() {
	String name = String.valueOf(reqData.get("platform"));
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_36 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 36);
	LinearLayout.LayoutParams lpItem = new LinearLayout.LayoutParams(dp_36, dp_36);
	final int dp_9 = cn.sharesdk.framework.utils.R.dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LinearLayout.LayoutParams(dp_36, dp_36));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		if (name != null && name.equals(platformList[i].getName())) {
			views[i].setVisibility(View.INVISIBLE);
			selection = i;

			// a statistics of Sharing
			ShareSDK.logDemoEvent(3, platformList[i]);
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_36 + dp_9), 0);
			return false;
		}
	});
}
 
源代码17 项目: BigApp_Discuz_Android   文件: EditPage.java
/** display platform list */
public void afterPlatformListGot() {
	int size = platformList == null ? 0 : platformList.length;
	views = new View[size];

	final int dp_24 = dipToPx(getContext(), 24);
	LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
	final int dp_9 = dipToPx(getContext(), 9);
	lpItem.setMargins(0, 0, dp_9, 0);
	FrameLayout.LayoutParams lpMask = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	lpMask.gravity = Gravity.LEFT | Gravity.TOP;
	int selection = 0;
	for (int i = 0; i < size; i++) {
		FrameLayout fl = new FrameLayout(getContext());
		fl.setLayoutParams(lpItem);
		if (i >= size - 1) {
			fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
		}
		llPlat.addView(fl);
		fl.setOnClickListener(this);

		ImageView iv = new ImageView(getContext());
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageBitmap(getPlatLogo(platformList[i]));
		iv.setLayoutParams(new FrameLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		fl.addView(iv);

		views[i] = new View(getContext());
		views[i].setBackgroundColor(0xcfffffff);
		views[i].setOnClickListener(this);
		String platformName = platformList[i].getName();
		for(Platform plat : platforms) {
			if(platformName.equals(plat.getName())) {
				views[i].setVisibility(View.INVISIBLE);
				selection = i;
			}
		}
		views[i].setLayoutParams(lpMask);
		fl.addView(views[i]);
	}

	final int postSel = selection;
	UIHandler.sendEmptyMessageDelayed(0, 333, new Callback() {
		public boolean handleMessage(Message msg) {
			HorizontalScrollView hsv = (HorizontalScrollView)llPlat.getParent();
			hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
			return false;
		}
	});
}
 
private void initView(Context context, AttributeSet attrs) {
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ReboundListView);

	headerProgressBarEnabled = a
			.getBoolean(
					R.styleable.ReboundListView_ReboundListView_FooterProgressBarEnabled,
					false);
	headerArrowEnabled = a.getBoolean(
			R.styleable.ReboundListView_ReboundListView_HeaderArrowEnabled,
			false);
	headerIconEnabled = a.getBoolean(
			R.styleable.ReboundListView_ReboundListView_HeaderIconEnabled,
			false);

	headerTimeEnabled = a.getBoolean(
			R.styleable.ReboundListView_ReboundListView_HeaderTimeEnabled,
			false);

	headerIconSrc = a
			.getDrawable(R.styleable.ReboundListView_ReboundListView_HeaderIconSrc);

	// 初始情况,设置下拉刷新view高度为0
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, 0);
	mContentView = (LinearLayout) LayoutInflater.from(context).inflate(
			R.layout.rebound_listview_header, null);
	addView(mContentView, lp);
	setGravity(Gravity.BOTTOM);

	mHintTextView = (TextView) findViewById(R.id.rebound_listview_header_hint_textview);

	mProgressBar = (ProgressBar) findViewById(R.id.rebound_listview_header_progressbar);
	if (headerProgressBarEnabled) {
		mProgressBar.setVisibility(VISIBLE);
	} else {
		mProgressBar.setVisibility(GONE);
	}

	mIconImageView = (ImageView) findViewById(R.id.rebound_listview_header_iv_icon);
	if (headerIconSrc != null) {
		mIconImageView.setVisibility(VISIBLE);
		mIconImageView.setImageDrawable(headerIconSrc);
	} else {
		mIconImageView.setVisibility(GONE);
	}

	mRotateUpAnim = new RotateAnimation(0.0f, -180.0f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateUpAnim.setDuration(ROTATE_ANIM_DURATION);
	mRotateUpAnim.setFillAfter(true);
	mRotateDownAnim = new RotateAnimation(-180.0f, 0.0f,
			Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateDownAnim.setDuration(ROTATE_ANIM_DURATION);
	mRotateDownAnim.setFillAfter(true);

	realHeaderHeight = DensityUtils.px2dip(context, 100);
}
 
源代码19 项目: Pi-Locker   文件: ShortcutSettings.java
@Override
protected void onCreate(Bundle b) {
	super.onCreate(b);

	actionBar = getSupportActionBar();
	actionBar.setBackgroundDrawable(new ColorDrawable(0xff00BCD4));
	actionBar.setDisplayShowTitleEnabled(false);
	actionBar.setDisplayShowTitleEnabled(true);
	actionBar.setTitle(Html
			.fromHtml("<font color='#ffffff'> <b> Shortcut </b> </font>"));
	actionBar.setDisplayHomeAsUpEnabled(true);

	mContent = new LinearLayout(this);
	mContent.setOrientation(LinearLayout.VERTICAL);
	mContent.setBackgroundColor(Color.WHITE);

	setContentView(mContent);

	for (int i = 0; i < CAPACITY; i++) {

		final int bb = i;

		final ShortCut txt = new ShortCut(getBaseContext(), null);

		final Handler h = new Handler();

		View v = new View(ShortcutSettings.this);

		LayoutParams vv = new LayoutParams(LayoutParams.MATCH_PARENT, 1);

		v.setBackgroundColor(0x33000000);
		v.setPadding(0, 5, 0, 5);

		mContent.addView(v, vv);

		String Sys = Settings.System.getString(getContentResolver(), "PiSC" + bb);
		ApplicationInfo ai = null;
		PackageManager pm;
		pm = getPackageManager();

		if (Sys != null) {

			try {

				ai = pm.getApplicationInfo(Sys, 0);
				String App_Name = (String) pm.getApplicationLabel(ai);
				Drawable Icon = pm.getApplicationIcon(ai);
				txt.setName(App_Name);
				txt.setImage(Icon);

			} catch (NameNotFoundException e) {

				e.printStackTrace();
			}

		}

		else if (Sys == null) {

		}

		txt.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {

				Toast.makeText(getApplicationContext(), "Please Wait..",
						Toast.LENGTH_LONG).show();

				PickerApp.setCurSor(bb);

				startActivity(new Intent(ShortcutSettings.this,
						PickerApp.class));

			}
		});

		mContent.addView(txt);

	}

}
 
源代码20 项目: Pi-Locker   文件: PickerApp.java
@Override
protected void onCreate(Bundle RainOfAlmas) {
	
	super.onCreate(RainOfAlmas);
	
		
	actionbar = getSupportActionBar();
	actionbar.setBackgroundDrawable(new ColorDrawable(0xff00BCD4));
	actionbar.setDisplayShowTitleEnabled(false);
	actionbar.setDisplayShowTitleEnabled(true);
	actionbar.setTitle(Html.fromHtml("<font color='#ffffff'> <b> Choose an app </b> </font>"));
    actionbar.setDisplayHomeAsUpEnabled(true);
       
	mContent = new LinearLayout(this);
	mContent.setOrientation(LinearLayout.VERTICAL);
	mContent.setVerticalScrollBarEnabled(false);

	mSuppler = new LinearLayout(this);
	mSuppler.setOrientation(LinearLayout.VERTICAL);
	
	sec = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

	sv = new ScrollView(getBaseContext());
	sv.addView(mContent);
	
	mSuppler.addView(sv);
	
	setContentView(mSuppler);
	
	
	SharedPreferences sp = getSharedPreferences("AlmasPicker", Context.MODE_PRIVATE);
	CurGet = sp.getString(PickerGetter, "");
	
	
	if (DEBUG) {
		
		if (CurGet == null | CurGet == "") {
			
			Log.e(TAG_NAME, "This is First View of AlmasPicker");
			Log.e(TAG_NAME, "Beause No Saved Data");
			
		}
		
		else {
			
			Log.i(TAG_NAME, "Saved Data Has Found");
			Log.d(TAG_NAME, "Package Name is "+CurGet);
		}
	}
	
	
	ArrayList<ResolveInfo> apps = getApps();
	
	for (int i = 0; i < apps.size(); i++) {
		
		ResolveInfo rInfo = apps.get(i);
		final Picker pick;
		final String pkg;
		PickerAdapter pa = new PickerAdapter(getBaseContext(), null);
		String ss = rInfo.activityInfo.loadLabel(pm).toString();
		Drawable dd = rInfo.activityInfo.loadIcon(pm);
		pick = new Picker(ss,dd);
		pa.setName(pick.getName());
		pa.setIcon(pick.getIcon());
		pkg = rInfo.activityInfo.packageName.toString();

		
		View v = new View(this);
		LayoutParams vv = new LayoutParams(LayoutParams.MATCH_PARENT ,1);

		v.setBackgroundColor(0x33000000);
		v.setPadding(0, 5, 0, 5);
		mContent.addView(v, vv );
		
		pa.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				
				// If You want to start the app
				Settings.System.putString(getContentResolver(), "PiSC"+ Cursor, pkg);
				save("pkg",pkg);
				
				finish();
				
				
			}
				
		});
		mContent.addView(pa);
	}
}