Java Code Examples for android.widget.LinearLayout.LayoutParams#setMargins()

The following examples show how to use android.widget.LinearLayout.LayoutParams#setMargins() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomDialog.java    From WhereYouGo with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: MainActivity.java    From spidey with GNU General Public License v3.0 6 votes vote down vote up
public void addView(View view, int margin) {
	/**
	 * <Button android:text="Scan Result 1" android:textSize="24sp"
	 * android:textColor="#000000"
	 * 
	 * android:background="#cc999999"
	 * android:layout_height="wrap_content"
	 * android:layout_width="match_parent" android:gravity="center"
	 * android:layout_margin="6dp"
	 */
	
	LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT,
			LayoutParams.WRAP_CONTENT);
	lp.setMargins(margin,margin,margin,margin);
	mViewResults.addView(view, lp);
	
	
}
 
Example 3
Source File: Home.java    From injor with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    SkinManager.getInstance().register(this);
    int buttonNum = PrefManager.getInstance(this).getInt(SettingActivity.BUTTON_NUM, 0);
    if (buttonNum > 0) {
        LinearLayout root = (LinearLayout) findViewById(R.id.root);
        int marginTop = dip2px(5);
        for (int i = 1; i <= buttonNum; i++) {
            Button button = new Button(this);
            button.setText(getString(R.string.dynamic_button) + " " + i);
            button.setTag("skin:btn_color:textColor|skin:btn_background:background|skin:font_size:textSize|skin:custom_font:typeface");
            LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            layoutParams.setMargins(0, marginTop, 0, 0);
            root.addView(button, layoutParams);
            SkinManager.getInstance().injectSkinAsync(button);
        }
    }
}
 
Example 4
Source File: WelcomeScreenFragmentExpList.java    From Gazetti_Newspaper_Reader with MIT License 5 votes vote down vote up
public static boolean handleBackPressed(){
    if(topLayerHidden){
        topLayer.setVisibility(View.VISIBLE);
        topLayerHidden = false;

        LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        params.setMargins(0,0,0,originalBottomMargin);
        bottomLayer.setLayoutParams(params);

        return false;
    } else {
        return true;
    }
}
 
Example 5
Source File: RationaleDialog.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    Drawable drawable = ContextCompat.getDrawable(context, drawables[i]);
    DrawableCompat.setTint(drawable, ContextCompat.getColor(context, R.color.white));
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(drawable);
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered : R.style.Theme_Signal_AlertDialog_Light_Cornered)
                        .setView(view);
}
 
Example 6
Source File: BaseActivity.java    From android-lite-orm with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_list_btn);
    TAG = this.getClass().getSimpleName();
    OrmLog.setTag(TAG);

    container = (LinearLayout) findViewById(R.id.container);
    scroll = (ScrollView) container.getParent();
    TextView tv = (TextView) container.findViewById(R.id.title);
    tv.setText(getMainTitle());
    mTvSubTitle = (TextView) container.findViewById(R.id.sub_title);

    String[] bttxt = getButtonTexts();
    if (bttxt != null) {
        for (int i = 0; i < bttxt.length; i++) {
            Button bt = new Button(this);
            LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
            int margin = getResources().getDimensionPixelSize(R.dimen.common_marin);
            lp.setMargins(margin, margin, margin, margin);
            bt.setId(i);
            bt.setText(bttxt[i]);
            bt.setOnClickListener(this);
            bt.setLayoutParams(lp);
            container.addView(bt);
        }
    }
}
 
Example 7
Source File: SettingActivity.java    From injor with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_setting);
	SkinManager.getInstance().register(this);
	asyncLoadBtn = (Button) findViewById(R.id.enable_async_load_skin);
	asyncLoadBtn.setText(SkinManager.getInstance().isAsyncLoadSkin() ? R.string.enable_async_load_skin : R.string.disable_async_load_skin);
	buttonNumEdit = (EditText) findViewById(R.id.button_num_edit);
	buttonNumEdit.setText("" + PrefManager.getInstance(this).getInt(BUTTON_NUM, 0));
	featureArea = (LinearLayout) findViewById(R.id.feature_area);
	int marginTop = dip2px(5);
	for (ISkinProcessor processor : SkinManager.getInstance().getProcessors()) {
		Button button = new Button(this);
		String feature = processor.getName();
		if (SkinManager.getInstance().isProcessorDisabled(feature)) {
			button.setText(getString(R.string.disabled_feature) + feature);
		} else {
			button.setText(getString(R.string.enabled_feature) + feature);
		}
		button.setTag("skin:btn_color:textColor");
		button.setOnClickListener(this);
		LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
		layoutParams.setMargins(0, marginTop, 0, 0);
		featureArea.addView(button, layoutParams);
		SkinManager.getInstance().injectSkinAsync(button);
	}
}
 
Example 8
Source File: RationaleDialog.java    From Silence with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(context.getResources().getDrawable(drawables[i]));
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context, R.style.RationaleDialog).setView(view);
}
 
Example 9
Source File: RationaleDialog.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(context.getResources().getDrawable(drawables[i]));
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context).setView(view);
}
 
Example 10
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private LinearLayout getPlatformList() {
	LinearLayout llToolBar = new LinearLayout(getContext());
	LayoutParams lpTb = new 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);
	LayoutParams lpShareTo = new 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);
	LayoutParams lpSv = new 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;
}
 
Example 11
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 5 votes vote down vote up
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LayoutParams lpMain = new 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());
	LayoutParams lpContent = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// share content editor
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(shareParamMap.get("text")));
	etContent.addTextChangedListener(this);
	LayoutParams lpEt = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

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

	return llMainBody;
}
 
Example 12
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private LinearLayout getPlatformList() {
	LinearLayout llToolBar = new LinearLayout(getContext());
	LayoutParams lpTb = new 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);
	LayoutParams lpShareTo = new 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);
	LayoutParams lpSv = new 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;
}
 
Example 13
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
private LinearLayout getMainBody() {
	LinearLayout llMainBody = new LinearLayout(getContext());
	llMainBody.setOrientation(LinearLayout.VERTICAL);
	LayoutParams lpMain = new 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());
	LayoutParams lpContent = new LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lpContent.weight = 1;
	llMainBody.addView(llContent, lpContent);

	// share content editor
	etContent = new EditText(getContext());
	etContent.setGravity(Gravity.LEFT | Gravity.TOP);
	etContent.setBackgroundDrawable(null);
	etContent.setText(String.valueOf(shareParamMap.get("text")));
	etContent.addTextChangedListener(this);
	LayoutParams lpEt = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	lpEt.weight = 1;
	etContent.setLayoutParams(lpEt);
	llContent.addView(etContent);

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

	return llMainBody;
}
 
Example 14
Source File: SimpleDialog.java    From microMathematics with GNU General Public License v3.0 5 votes vote down vote up
public void disableButton(int id)
{
    View button = findViewById(id);
    final View other = findViewById(id == R.id.dialog_button_ok ? R.id.dialog_button_cancel : R.id.dialog_button_ok);
    if (button != null && other != null)
    {
        button.setVisibility(View.GONE);
        LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        lp.setMargins(0, 0, 0, getContext().getResources().getDimensionPixelSize(R.dimen.dialog_buttons_margin));
        other.setLayoutParams(lp);
        findViewById(R.id.dialog_button_devider).setVisibility(View.GONE);
    }
}
 
Example 15
Source File: EditPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
/** 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;
		}
	});
}
 
Example 16
Source File: FollowListPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	FollowListItem item = null;
	boolean simpleMode = "FacebookMessenger".equals(platform.getName());
	if (convertView == null) {
		LinearLayout llItem = new LinearLayout(parent.getContext());
		item = new FollowListItem();
		llItem.setTag(item);
		convertView = llItem;

		int dp_52 = com.mob.tools.utils.R.dipToPx(getContext(), 52);
		int dp_10 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 10);
		int dp_5 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 5);

		if(!simpleMode) {
			item.aivIcon = new AsyncImageView(getContext());
			LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
			lpIcon.gravity = Gravity.CENTER_VERTICAL;
			lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
			item.aivIcon.setLayoutParams(lpIcon);
			llItem.addView(item.aivIcon);
		}

		LinearLayout llText = new LinearLayout(parent.getContext());
		llText.setPadding(0, dp_10, dp_10, dp_10);
		llText.setOrientation(LinearLayout.VERTICAL);
		LayoutParams lpText = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpText.gravity = Gravity.CENTER_VERTICAL;
		lpText.weight = 1;
		llText.setLayoutParams(lpText);
		llItem.addView(llText);

		item.tvName = new TextView(parent.getContext());
		item.tvName.setTextColor(0xff000000);
		item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
		item.tvName.setSingleLine();
		if(simpleMode) {
			item.tvName.setPadding(dp_10, 0, 0, 0);
		}
		llText.addView(item.tvName);

		if(!simpleMode) {
			item.tvSign = new TextView(parent.getContext());
			item.tvSign.setTextColor(0x7f000000);
			item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
			item.tvSign.setSingleLine();
			llText.addView(item.tvSign);
		}

		item.ivCheck = new ImageView(parent.getContext());
		item.ivCheck.setPadding(0, 0, dp_10, 0);
		LayoutParams lpCheck = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpCheck.gravity = Gravity.CENTER_VERTICAL;
		item.ivCheck.setLayoutParams(lpCheck);
		llItem.addView(item.ivCheck);
	} else {
		item = (FollowListItem) convertView.getTag();
	}

	Following following = getItem(position);
	item.tvName.setText(following.screenName);
	if(!simpleMode) {
		item.tvSign.setText(following.description);
	}
	item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
	if(!simpleMode) {
		if (isFling()) {
			Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
			if (bm != null && !bm.isRecycled()) {
				item.aivIcon.setImageBitmap(bm);
			} else {
				item.aivIcon.execute(null, 0);
			}
		} else {
			item.aivIcon.execute(following.icon,0);
		}
	}

	if (position == getCount() - 1) {
		next();
	}
	return convertView;
}
 
Example 17
Source File: FollowListPage.java    From BigApp_WordPress_Android with Apache License 2.0 4 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	FollowListItem item = null;
	boolean simpleMode = "FacebookMessenger".equals(platform.getName());
	if (convertView == null) {
		LinearLayout llItem = new LinearLayout(parent.getContext());
		item = new FollowListItem();
		llItem.setTag(item);
		convertView = llItem;

		int dp_52 = com.mob.tools.utils.R.dipToPx(getContext(), 52);
		int dp_10 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 10);
		int dp_5 = com.mob.tools.utils.R.dipToPx(parent.getContext(), 5);

		if(!simpleMode) {
			item.aivIcon = new AsyncImageView(getContext());
			LayoutParams lpIcon = new LayoutParams(dp_52, dp_52);
			lpIcon.gravity = Gravity.CENTER_VERTICAL;
			lpIcon.setMargins(dp_10, dp_5, dp_10, dp_5);
			item.aivIcon.setLayoutParams(lpIcon);
			llItem.addView(item.aivIcon);
		}

		LinearLayout llText = new LinearLayout(parent.getContext());
		llText.setPadding(0, dp_10, dp_10, dp_10);
		llText.setOrientation(LinearLayout.VERTICAL);
		LayoutParams lpText = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpText.gravity = Gravity.CENTER_VERTICAL;
		lpText.weight = 1;
		llText.setLayoutParams(lpText);
		llItem.addView(llText);

		item.tvName = new TextView(parent.getContext());
		item.tvName.setTextColor(0xff000000);
		item.tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
		item.tvName.setSingleLine();
		if(simpleMode) {
			item.tvName.setPadding(dp_10, 0, 0, 0);
		}
		llText.addView(item.tvName);

		if(!simpleMode) {
			item.tvSign = new TextView(parent.getContext());
			item.tvSign.setTextColor(0x7f000000);
			item.tvSign.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
			item.tvSign.setSingleLine();
			llText.addView(item.tvSign);
		}

		item.ivCheck = new ImageView(parent.getContext());
		item.ivCheck.setPadding(0, 0, dp_10, 0);
		LayoutParams lpCheck = new LayoutParams(
				LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		lpCheck.gravity = Gravity.CENTER_VERTICAL;
		item.ivCheck.setLayoutParams(lpCheck);
		llItem.addView(item.ivCheck);
	} else {
		item = (FollowListItem) convertView.getTag();
	}

	Following following = getItem(position);
	item.tvName.setText(following.screenName);
	if(!simpleMode) {
		item.tvSign.setText(following.description);
	}
	item.ivCheck.setImageBitmap(following.checked ? bmChd : bmUnch);
	if(!simpleMode) {
		if (isFling()) {
			Bitmap bm = BitmapProcessor.getBitmapFromCache(following.icon);
			if (bm != null && !bm.isRecycled()) {
				item.aivIcon.setImageBitmap(bm);
			} else {
				item.aivIcon.execute(null, 0);
			}
		} else {
			item.aivIcon.execute(following.icon,0);
		}
	}

	if (position == getCount() - 1) {
		next();
	}
	return convertView;
}
 
Example 18
Source File: EditPage.java    From BigApp_Discuz_Android with Apache License 2.0 4 votes vote down vote up
/** 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;
		}
	});
}
 
Example 19
Source File: UIActionSheetDialog.java    From Auie with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 构建内容视图 - IOS
 * @return 内容视图
 */
@SuppressWarnings("deprecation")
private View createContentViewForIOS(){
	//根布局
	rootLayout = new LinearLayout(context);
	rootLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootLayout.setOrientation(LinearLayout.VERTICAL);
	rootLayout.setBackgroundColor(Color.parseColor("#77000000"));
	rootLayout.setGravity(Gravity.BOTTOM);
	
	parentLayout = new LinearLayout(context);
	parentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	parentLayout.setOrientation(LinearLayout.VERTICAL);
	parentLayout.setBackgroundColor(Color.parseColor("#00000000"));
	
	LinearLayout childLayout = new LinearLayout(context);
	LayoutParams childParams = getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	childParams.setMargins(8 * DP, 0, 8 * DP, 0);
	childLayout.setLayoutParams(childParams);
	childLayout.setOrientation(LinearLayout.VERTICAL);
	childLayout.setBackgroundDrawable(UEImage.createBackground(Color.WHITE, 204, 10));
	
	//标题
	TextView titleTextView = new TextView(context);
	titleTextView.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	titleTextView.setPadding(0, 10 * DP, 0, 10 * DP);
	titleTextView.setMinHeight(45 * DP);
	titleTextView.setTextSize(14);
	titleTextView.setGravity(Gravity.CENTER);
	titleTextView.setTextColor(Color.parseColor("#8F8F8F"));
	if (title == null) {
		titleTextView.setVisibility(View.GONE);
	}else{
		titleTextView.setVisibility(View.VISIBLE);
		titleTextView.setText(title);
	}
	
	//内容外层布局
	sheetLayout = new ScrollView(context);
	sheetLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	sheetLayout.setFadingEdgeLength(0);
	
	//内容内层布局
	contentLayout = new LinearLayout(context);
	contentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	contentLayout.setOrientation(LinearLayout.VERTICAL);
	sheetLayout.addView(contentLayout);
	
	//取消按钮
	final TextView cancelTextView = new TextView(context);
	LayoutParams params = getParams(LayoutParams.MATCH_PARENT, 45 * DP);
	params.setMargins(8 * DP, 8 * DP, 8 * DP, 8 * DP);
	cancelTextView.setLayoutParams(params);
	cancelTextView.setTextColor(Color.parseColor("#3DB399"));
	cancelTextView.setTextSize(16);
	cancelTextView.setGravity(Gravity.CENTER);
	cancelTextView.setText("取消");
	cancelTextView.setBackgroundDrawable(UEImage.createBackground(Color.WHITE, 204, 10));
	cancelTextView.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			dismiss();
		}
	});
	
	//控件创建结束
	childLayout.addView(titleTextView);
	childLayout.addView(sheetLayout);
	parentLayout.addView(childLayout);
	parentLayout.addView(cancelTextView);
	rootLayout.addView(parentLayout);
	if (typeface != null) {
		titleTextView.setTypeface(typeface);
		cancelTextView.setTypeface(typeface);
	}
	return rootLayout;
}
 
Example 20
Source File: UIActionSheetDialog.java    From Auie with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 构建内容视图 - ANDROID
 * @return 内容视图
 */
private View createContentViewForANDROID(){
	//根布局
	rootLayout = new LinearLayout(context);
	rootLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	rootLayout.setOrientation(LinearLayout.VERTICAL);
	rootLayout.setBackgroundColor(Color.parseColor("#55000000"));
	rootLayout.setGravity(Gravity.BOTTOM);
	
	parentLayout = new LinearLayout(context);
	parentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	parentLayout.setOrientation(LinearLayout.VERTICAL);
	parentLayout.setBackgroundColor(backgroundColor);
	
	LinearLayout childLayout = new LinearLayout(context);
	LayoutParams childParams = getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	childLayout.setLayoutParams(childParams);
	childLayout.setOrientation(LinearLayout.VERTICAL);
	
	//标题
	TextView titleTextView = new TextView(context);
	titleTextView.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	titleTextView.setMinHeight(48 * DP);
	titleTextView.setTextSize(12);
	titleTextView.setGravity(Gravity.CENTER);
	titleTextView.setTextColor(titleColor);
	if (title == null) {
		titleTextView.setVisibility(View.GONE);
	}else{
		titleTextView.setVisibility(View.VISIBLE);
		titleTextView.setText(title);
	}
	
	//内容外层布局
	sheetLayout = new ScrollView(context);
	sheetLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	sheetLayout.setFadingEdgeLength(0);
	
	//内容内层布局
	contentLayout = new LinearLayout(context);
	contentLayout.setLayoutParams(getParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	contentLayout.setOrientation(LinearLayout.VERTICAL);
	sheetLayout.addView(contentLayout);
	
	//取消按钮
	final TextView cancelTextView = new TextView(context);
	LayoutParams params = getParams(LayoutParams.MATCH_PARENT, 52 * DP);
	params.setMargins(0, 8 * DP, 0, 0);
	cancelTextView.setLayoutParams(params);
	cancelTextView.setTextColor(cancelColor);
	cancelTextView.setTextSize(16);
	cancelTextView.setGravity(Gravity.CENTER);
	cancelTextView.setText("取消");
	cancelTextView.setBackgroundColor(itemBackgroundColor);
	cancelTextView.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			dismiss();
		}
	});
	
	//控件创建结束
	childLayout.addView(titleTextView);
	childLayout.addView(sheetLayout);
	parentLayout.addView(childLayout);
	parentLayout.addView(cancelTextView);
	rootLayout.addView(parentLayout);
	if (typeface != null) {
		titleTextView.setTypeface(typeface);
		cancelTextView.setTypeface(typeface);
	}
	return rootLayout;
}