Java Code Examples for android.widget.LinearLayout.addView()

The following are Jave code examples for showing how to use addView() of the android.widget.LinearLayout class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AdPlayBanner   File: ScrollerPager.java   View Source Code Vote up 6 votes
/**
 * 初始化数字页码
 */
private void initPageNumber() {
    if (IndicatorManager.getInstance().getIndicatorType() == NUMBER_INDICATOR) {
        mPageNumberLayout = new LinearLayout(getContext());
        mPageNumberLayout.setOrientation(LinearLayout.HORIZONTAL);
        mPageNumberLayout.setGravity(Gravity.CENTER);

        mPageNumberLayout.removeAllViews();

        mNumberViews = new NumberView[mInfos.size()];

        for (int i = 0; i < mInfos.size(); i++) {
            NumberView numberView;
            if (i == mSelectedIndex) {
                numberView = new NumberView(getContext(), NumberView.mNumberViewSelectedColor);
            } else {
                numberView = new NumberView(getContext(), NumberView.mNumberViewNormalColor);
            }
            numberView.setNumber(i + 1);
            mNumberViews[i] = numberView;
            mPageNumberLayout.addView(mNumberViews[i]);
        }
    }
}
 
Example 2
Project: boohee_v5.6   File: DietPlanActivity.java   View Source Code Vote up 6 votes
private View generateDietCard(DietPlan plan) {
    if (plan == null || plan.detail == null) {
        return null;
    }
    View periodView = LayoutInflater.from(this).inflate(R.layout.ob, this.llPlan, false);
    LinearLayout itemGroup = (LinearLayout) periodView.findViewById(R.id.ll_list);
    TextView tvCalory = (TextView) periodView.findViewById(R.id.tv_calory);
    ((TextView) periodView.findViewById(R.id.tv_name)).setText(plan.name);
    tvCalory.setText(Math.round(plan.calory) + "千卡");
    for (int i = 0; i < plan.detail.size(); i++) {
        boolean z;
        DietPlanItem dietPlanItem = (DietPlanItem) plan.detail.get(i);
        ViewGroup viewGroup = this.llPlan;
        if (i == plan.detail.size() - 1) {
            z = true;
        } else {
            z = false;
        }
        itemGroup.addView(generatePlanItem(dietPlanItem, viewGroup, z));
    }
    return periodView;
}
 
Example 3
Project: SwipeMenuAndPullToRefresh   File: SMExpandView.java   View Source Code Vote up 6 votes
private void addItem(SwipeMenuItem item, int id) {
	LayoutParams params = new LayoutParams(item.getWidth(),
			LayoutParams.MATCH_PARENT);
	LinearLayout parent = new LinearLayout(getContext());
	parent.setId(id);
	parent.setGravity(Gravity.CENTER);
	parent.setOrientation(LinearLayout.VERTICAL);
	parent.setLayoutParams(params);
	parent.setBackgroundDrawable(item.getBackground());
	parent.setOnClickListener(this);

	addView(parent);

	if (item.getIcon() != null) {
		parent.addView(createIcon(item));
	}
	if (!TextUtils.isEmpty(item.getTitle())) {
		parent.addView(createTitle(item));
	}

}
 
Example 4
Project: MyCalendar   File: MainActivity.java   View Source Code Vote up 6 votes
private void drawHourLabel() {
    LinearLayout weekViewHoursHolder = findViewById(R.id.activity_main_hours_holder);

    TextView tv;
    int rowHeight = mResources.getDimensionPixelOffset(R.dimen.week_view_row_height);
    int minHeight = rowHeight;
    int marginTop;
    int marginBottom;
    int marginLeftRight = mResources.getDimensionPixelSize(R.dimen.hour_text_margin_left_right);
    for (int i = 1; i < 24; i++) {
        if (i == 1) {
            marginTop = rowHeight / 2;
        } else {
            marginTop = 0;
        }
        if (i == 23) {
            marginBottom = rowHeight / 2;
        } else {
            marginBottom = 0;
        }
        String s = DateTimeHelper.getHourMinuteString(i, 0, true, false);
        tv = createTextView(mContext, s, minHeight, marginTop, marginBottom, marginLeftRight);
        weekViewHoursHolder.addView(tv);
    }
}
 
Example 5
Project: quickhybrid-android   File: DialogUtil.java   View Source Code Vote up 5 votes
/**
 * 时间选择对话框
 *
 * @param con      上下文
 * @param title    标题
 * @param listener 选择事件
 * @param cal      默认时间
 */
public static void pickTime(Context con, String title, Calendar cal, final OnTimeSetListener listener) {
    LinearLayout ll = new LinearLayout(con);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ll.setLayoutParams(layoutParams);
    ll.setOrientation(LinearLayout.VERTICAL);
    //添加一条线
    LinearLayout line = new LinearLayout(con);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
    line.setBackgroundColor(con.getResources().getColor(R.color.line));
    line.setLayoutParams(lp);
    ll.addView(line);
    //添加选择器控件
    final TimePicker timePicker = new TimePicker(con, null, themeId);
    timePicker.setLayoutParams(layoutParams);
    timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
    timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
    timePicker.setIs24HourView(true);
    ll.addView(timePicker);
    QuickDialog.Builder builder = new QuickDialog.Builder(con);
    builder.setContentView(ll);
    builder.setTitle(title);
    builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            listener.onTimeSet(timePicker, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
        }
    });
    builder.create().show();
}
 
Example 6
Project: DraggableTreeView   File: DraggableTreeView.java   View Source Code Vote up 5 votes
private void addToView(LinearLayout linearLayout,TreeNode node){
    for(int i = 0;i < node.getChildren().size();i++) {
        View child = node.getChildren().get(i).getView();
        if(child.getParent().getParent() != null) {
            ((ViewGroup)child.getParent().getParent()).removeView((View) child.getParent());
        }
        linearLayout.addView(((View)child.getParent()));
        addToView(linearLayout,node.getChildren().get(i));
    }
}
 
Example 7
Project: 3DPrint-Controller   File: BaseActivity.java   View Source Code Vote up 5 votes
@Override
public void setContentView(View view) {
    LinearLayout rootLayout = (LinearLayout) findViewById(R.id.root_layout);
    if (rootLayout == null) return;

    rootLayout.addView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    initToolbar();
}
 
Example 8
Project: GitHub   File: ContactListPageLayout.java   View Source Code Vote up 5 votes
protected void onCreateContent(LinearLayout parent) {
	ContactsListView contactsList = new ContactsListView(context);
	contactsList.setId(ResHelper.getIdRes(context, "clContact"));
	LinearLayout.LayoutParams listParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT, 1);
	contactsList.setLayoutParams(listParams);

	parent.addView(contactsList);
}
 
Example 9
Project: BBSSDK-for-Android   File: BasePageWithTitle.java   View Source Code Vote up 5 votes
protected View onCreateView(Context context) {
		mainLayout = new LinearLayout(context);
		mainLayout.setBackgroundResource(ResHelper.getColorRes(context, "bbs_title_bg"));
		mainLayout.setOrientation(LinearLayout.VERTICAL);
		mainLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

		titleBar = new TitleBar(context) {
			@Override
			protected View getCenterView() {
				View centerview = getTitleCenterView();
				if (centerview == null) {
					return super.getCenterView();
				}
				return centerview;
			}
		};
		LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
		mainLayout.addView(titleBar, llp);

		vLine = new View(context);
		vLine.setBackgroundResource(ResHelper.getColorRes(context, "bbs_mainviewtitle_bg"));
		mainLayout.addView(vLine, ViewGroup.LayoutParams.MATCH_PARENT, ResHelper.dipToPx(context, 1) / 2);
		vLine.setVisibility(View.GONE);

		View contentView = onCreateContentView(context);
//		contentView.setBackgroundResource(ResHelper.getColorRes(context, "bbs_bg"));
		llp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
		llp.weight = 1;
		mainLayout.addView(contentView, llp);

		titleBar.setOnClickListener(newTitleBarClickListener());
		return mainLayout;
	}
 
Example 10
Project: Huochexing12306   File: EditPage.java   View Source Code Vote up 5 votes
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;
}
 
Example 11
Project: androidgithub   File: EditPageLand.java   View Source Code Vote up 5 votes
public void onCreate() {
	super.onCreate();

	int screenHeight = R.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example 12
Project: LQRWeChat   File: EditPageLand.java   View Source Code Vote up 5 votes
private void initBottom(LinearLayout llBottom, float ratio) {
	LinearLayout llAt = new LinearLayout(activity);
	llAt.setPadding(0, 0, 0, 5);
	llAt.setBackgroundColor(0xffffffff);
	int bottomHeight = (int) (DESIGN_BOTTOM_HEIGHT * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, bottomHeight);
	llBottom.addView(llAt, lp);

	tvAt = new TextView(activity);
	tvAt.setTextColor(0xff3b3b3b);
	tvAt.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	tvAt.setGravity(Gravity.BOTTOM);
	tvAt.setText("@");
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	tvAt.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	llAt.addView(tvAt, lp);
	tvAt.setOnClickListener(this);
	if (isShowAtUserLayout(platform.getName())) {
		tvAt.setVisibility(View.VISIBLE);
	} else {
		tvAt.setVisibility(View.INVISIBLE);
	}

	tvTextCouter = new TextView(activity);
	tvTextCouter.setTextColor(0xff3b3b3b);
	tvTextCouter.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
	tvTextCouter.setGravity(Gravity.BOTTOM | Gravity.RIGHT);
	onTextChanged(etContent.getText(), 0, 0, 0);
	tvTextCouter.setPadding(padding, 0, padding, 0);
	lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
	lp.weight = 1;
	llAt.addView(tvTextCouter, lp);

	View v = new View(activity);
	v.setBackgroundColor(0xffcccccc);
	int px1 = ratio > 1 ? ((int) ratio) : 1;
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, px1);
	llBottom.addView(v, lp);
}
 
Example 13
Project: Real-estate-agent-management-system   File: SelectActivity.java   View Source Code Vote up 4 votes
/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See https://g.co/AppIndexing/AndroidStudio for more information.
 */

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_select);

    ll_select_content = (LinearLayout) findViewById(R.id.ll_select_content);
    mBuyHomeViewHolder = new BuyHomeViewHolder(ll_select_content);
    mBuyHomeViewHolder.init();
    removeOtherView();
    ll_select_content.addView(mBuyHomeViewHolder.getView());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setItemIconTintList(null);
    navigationView.setNavigationItemSelectedListener(this);

    Intent intent = getIntent();
    final String username = intent.getStringExtra("username");
    tv0 = (TextView) navigationView.getHeaderView(0).findViewById(R.id.textView0);
    tv0.setText(username);

    //String path = "http://172.16.64.203:8080/数据库查询/SelectHome";
    String path = RestConstants.API_HOST + "数据库查询/SelectHome";
    //String path = "http://192.168.43.191:8080/数据库查询/SelectHome";
    //String path = "http://172.16.88.222:8080/数据库查询/RegiStration";
    Map<String, String> params = new HashMap<>();
    params.put("1", "1");
    OkHttpManager.getInstance().post(path, params, new OnHttpCallback() {
        @Override
        public void onSuccess(String str) {
            String s[] = str.split("%");
            String ss[] = s[0].split("#");
            String sa[][] = new String[ss.length][];
            for(int i=0;i<ss.length;i++){
                sa[i] = ss[i].split("@");
            }
            //int i = 0;
            List<Home> list = new ArrayList<Home>();
            for (int i=0;i<sa.length;i++){
                for (int j=0;j<sa[i].length;j+=17) {
                    System.out.println(sa[i][j]+"++++"+sa[i][j+16]);
                    Home home = new Home(username,sa[i][j],sa[i][j+16]);
                    list.add(home);
                }
            }

            mBuyHomeViewHolder.notifySetDataChanged(list);

            if("读取成功".equals(s[1])){
                Toast.makeText(SelectActivity.this,s[1], Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onError(Throwable e) {
            e.printStackTrace();
            Toast.makeText(SelectActivity.this, "读取失败,请重新读取!", Toast.LENGTH_LONG).show();
        }
    });
}
 
Example 14
Project: PlusGram   File: changeAdapter.java   View Source Code Vote up 4 votes
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {

    View x = null;
    if (x == null) {


        LinearLayout base = new LinearLayout(context);
        base.setOrientation(LinearLayout.VERTICAL);


        LinearLayout l = new LinearLayout(context);
        l.setOrientation(LinearLayout.VERTICAL);
        l.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
        l.setPadding(50, 0, 50, 0);

        typetext = new TextView(context);
        typetext.setPadding(28, 0, 28, 0);
        typetext.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
        typetext.setTextColor(typecolor);
        typetext.setTextSize(14);

        timetext = new TextView(context);
        timetext.setPadding(28, 0, 28, 0);
        timetext.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
        timetext.setTextColor(nameColor);
        timetext.setTextSize(14);

        setText(changes.get(position), context);
        l.addView(typetext);
        l.addView(timetext);

        x = new CustomUserCell(context, 5, 1, false);
        base.addView(x, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

        base.addView(l, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
        base.addView(new DividerCell(context), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));


        convertView = base;
        ((CustomUserCell) x).setStatusColors(0xffa8a8a8, 0xff3b84c0);
        convertView.setTag("Contacts");
    }


    TLRPC.User user = MessagesController.getInstance().getUser(changes.get(position).getUid());
    ((CustomUserCell) x).setData(user, null, null, 0);
    convertView.setTag("Contacts");
    return convertView;
}
 
Example 15
Project: Mybilibili   File: EditPagePort.java   View Source Code Vote up 4 votes
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.VERTICAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.leftMargin = lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 16
Project: LQRWeChat-master   File: EditPageLand.java   View Source Code Vote up 4 votes
private void initBody(RelativeLayout rlBody, float ratio) {
	svContent = new ScrollView(activity);
	rlBody.addView(svContent, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	LinearLayout llContent = new LinearLayout(activity);
	llContent.setOrientation(LinearLayout.HORIZONTAL);
	svContent.addView(llContent, new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

	etContent = new EditText(activity);
	int padding = (int) (DESIGN_LEFT_PADDING * ratio);
	etContent.setPadding(padding, padding, padding, padding);
	etContent.setBackgroundDrawable(null);
	etContent.setTextColor(0xff3b3b3b);
	etContent.setTextSize(TypedValue.COMPLEX_UNIT_SP, 21);
	etContent.setText(sp.getText());
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	llContent.addView(etContent, lp);
	etContent.addTextChangedListener(this);

	rlThumb = new RelativeLayout(activity);
	rlThumb.setBackgroundColor(0xff313131);
	int	thumbWidth = (int) (DESIGN_THUMB_HEIGHT_L * ratio);
	int	xWidth = (int) (DESIGN_REMOVE_THUMB_HEIGHT_L * ratio);
	lp = new LinearLayout.LayoutParams(thumbWidth, thumbWidth);
	lp.rightMargin = lp.bottomMargin = lp.topMargin = padding;
	llContent.addView(rlThumb, lp);

	aivThumb = new AsyncImageView(activity) {
		public void onImageGot(String url, Bitmap bm) {
			thumb = bm;
			super.onImageGot(url, bm);
		}
	};
	aivThumb.setScaleToCropCenter(true);
	RelativeLayout.LayoutParams rllp = new RelativeLayout.LayoutParams(thumbWidth, thumbWidth);
	rlThumb.addView(aivThumb, rllp);
	aivThumb.setOnClickListener(this);
	initThumb(aivThumb);

	xvRemove = new XView(activity);
	xvRemove.setRatio(ratio);
	rllp = new RelativeLayout.LayoutParams(xWidth, xWidth);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_TOP);
	rllp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	rlThumb.addView(xvRemove, rllp);
	xvRemove.setOnClickListener(this);
}
 
Example 17
Project: Mybilibili   File: FriendListPage.java   View Source Code Vote up 4 votes
public void onCreate() {
	activity.getWindow().setBackgroundDrawable(new ColorDrawable(0xfff3f3f3));

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	float ratio = getRatio();
	int titleHeight = (int) (getDesignTitleHeight() * ratio);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	View line = new View(activity);
	LinearLayout.LayoutParams lpline = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, (int) (ratio < 1 ? 1 : ratio));
	line.setBackgroundColor(0xffdad9d9);
	llPage.addView(line, lpline);

	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);

	// 关注(或朋友)列表
	PullToRequestView followList = new PullToRequestView(getContext());
	FrameLayout.LayoutParams lpLv = new FrameLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
	followList.setLayoutParams(lpLv);
	flPage.addView(followList);

	adapter = new FriendAdapter(this, followList);
	adapter.setPlatform(platform);
	adapter.setRatio(ratio);
	adapter.setOnItemClickListener(this);
	followList.setAdapter(adapter);

	// 请求数据
	followList.performPullingDown(true);
}
 
Example 18
Project: LiuAGeAndroid   File: PlatformPage.java   View Source Code Vote up 4 votes
public void onCreate() {
	activity.getWindow().setBackgroundDrawable(new ColorDrawable(0x4c000000));
	initAnims();

	LinearLayout llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	TextView vTop = new TextView(activity);
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	lp.weight = 1;
	vTop.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			finish();
		}
	});
	llPage.addView(vTop, lp);

	llPanel = new LinearLayout(activity);
	llPanel.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(
			LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPanel.setAnimation(animShow);
	llPage.addView(llPanel, lp);

	MobViewPager mvp = new MobViewPager(activity);
	ArrayList<Object> cells = collectCells();
	PlatformPageAdapter adapter = newAdapter(cells);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getPanelHeight());
	llPanel.addView(mvp, lp);

	IndicatorView vInd = new IndicatorView(activity);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, adapter.getBottomHeight());
	llPanel.addView(vInd, lp);

	vInd.setScreenCount(adapter.getCount());
	vInd.onScreenChange(0, 0);
	adapter.setIndicator(vInd);
	mvp.setAdapter(adapter);
}
 
Example 19
Project: PHEmptyDataSetForAndroid   File: MainActivity.java   View Source Code Vote up 4 votes
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final Button btn = new Button(this);
        btn.setBackgroundColor(Color.GREEN);

//        testV.getHeight();
//        testV.setBackgroundColor(0x125995);
//        testV2.setText("sdsaddfsdfsdfsd");

        RelativeLayout.LayoutParams param1 = new  RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,400);
        RelativeLayout.LayoutParams param2 = new  RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,800);
        param1.addRule(RelativeLayout.CENTER_IN_PARENT);
        param2.addRule(RelativeLayout.CENTER_IN_PARENT);



        btn.setLayoutParams(param2);
      final   LinearLayout mainL = new LinearLayout(this);
        ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,800);


       int  ja = param1.width;
//        testV2.setLayoutParams(param1);

//        mainL.addView(testV);
        mainL.addView(btn);
       btn.setText("hello!");

        final PHEmptyDataSet testV2 = new PHEmptyDataSet(btn);
        testV2.delegate = this;
        testV2.setBackgroundColor(Color.CYAN);

       btn.setOnClickListener(new View.OnClickListener() {
           @Override
           public void onClick(View v) {
               testV2.noNetWork();

           }
       });

        mainL.setLayoutParams(param);
        setContentView(mainL);
        mainL.setBackgroundColor(Color.RED);
    }
 
Example 20
Project: qmui   File: QMUIDialogBuilder.java   View Source Code Vote up 4 votes
/**
 * 创建底部的操作栏区域
 */
protected void onCreateHandlerBar(final QMUIDialog dialog, ViewGroup parent) {
    int size = mActions.size();
    if (size > 0 || mLeftAction != null) {
        mActionContainer = new LinearLayout(mContext);
        mActionContainer.setOrientation(LinearLayout.HORIZONTAL);
        mActionContainer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        mActionContainer.setPadding(
                QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_action_container_margin_horizontal),
                0,
                QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_action_container_margin_horizontal),
                QMUIResHelper.getAttrDimen(mContext, R.attr.qmui_dialog_action_container_margin_bottom));
        if (mLeftAction != null) {
            mActionContainer.addView(mLeftAction.generateActionView(mContext, mDialog, 0, false));
        }
        View space = new View(mContext);
        LinearLayout.LayoutParams spaceLp = new LinearLayout.LayoutParams(0, 0);
        spaceLp.weight = 1;
        space.setLayoutParams(spaceLp);
        mActionContainer.addView(space);

        for (int i = 0; i < size; i++) {
            QMUIDialogAction action = mActions.get(i);
            mActionContainer.addView(action.generateActionView(mContext, mDialog, i, true));
        }

        mActionContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                int width = right - left;
                int childCount = mActionContainer.getChildCount();
                if (childCount > 0) {
                    View lastChild = mActionContainer.getChildAt(childCount - 1);
                    // 如果ActionButton的宽度过宽,则减小padding
                    if (lastChild.getRight() > width) {
                        int childPaddingHor = Math.max(0, lastChild.getPaddingLeft() - QMUIDisplayHelper.dp2px(mContext, 3));
                        for (int i = 0; i < childCount; i++) {
                            mActionContainer.getChildAt(i).setPadding(childPaddingHor, 0, childPaddingHor, 0);
                        }
                    }
                }

            }
        });
        parent.addView(mActionContainer);

    }
}