Beispiel #1
0
  private void createTopBanner(Context context) {
    int smallMargin = LayoutUtil.getSmallMargin();
    int midMargin = LayoutUtil.getMediumMargin();

    mTopBanner = new RelativeLayout(context);
    mTopBanner.setBackgroundResource(R.drawable.stone_bg);
    RelativeLayout.LayoutParams topViewLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    topViewLP.width = LayoutUtil.getNavigationPanelWidth();
    topViewLP.height = LayoutUtil.getGalleryTopPanelHeight();
    mTopBanner.setLayoutParams(topViewLP);
    this.addView(mTopBanner, topViewLP);

    mAvatarBtn = new HaloButton(context, R.drawable.avatar_2);
    RelativeLayout.LayoutParams avatarLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    avatarLP.leftMargin = smallMargin;
    avatarLP.width = DensityAdaptor.getDensityIndependentValue(32);
    avatarLP.height = DensityAdaptor.getDensityIndependentValue(32);
    avatarLP.addRule(RelativeLayout.CENTER_VERTICAL);
    mAvatarBtn.setLayoutParams(avatarLP);
    mTopBanner.addView(mAvatarBtn);

    mNameTextView = new TextView(context);
    mNameTextView.setText("Tom");
    mNameTextView.setTextSize(UIConfig.getUserLabelTextSize());
    mNameTextView.setTextColor(UIConfig.getLightTextColor());
    RelativeLayout.LayoutParams nameTextLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    nameTextLP.leftMargin = DensityAdaptor.getDensityIndependentValue(36);
    nameTextLP.addRule(RelativeLayout.CENTER_VERTICAL);
    mNameTextView.setLayoutParams(nameTextLP);
    mTopBanner.addView(mNameTextView);

    View separator = ControlFactory.createVertSeparatorForRelativeLayout(context);
    RelativeLayout.LayoutParams separatorLP = (LayoutParams) separator.getLayoutParams();
    separatorLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    separatorLP.rightMargin = DensityAdaptor.getDensityIndependentValue(48);
    separator.setLayoutParams(separatorLP);
    mTopBanner.addView(separator);

    mLogoutBtn = new HaloButton(context, R.drawable.logout);
    RelativeLayout.LayoutParams logoutLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    logoutLP.rightMargin = midMargin;
    logoutLP.width = DensityAdaptor.getDensityIndependentValue(32);
    logoutLP.height = DensityAdaptor.getDensityIndependentValue(32);
    logoutLP.addRule(RelativeLayout.CENTER_VERTICAL);
    logoutLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mLogoutBtn.setLayoutParams(logoutLP);
    mTopBanner.addView(mLogoutBtn);

    mLoginBtn = new HaloButton(context, R.drawable.login);
    RelativeLayout.LayoutParams loginLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    loginLP.rightMargin = midMargin;
    loginLP.width = DensityAdaptor.getDensityIndependentValue(32);
    loginLP.height = DensityAdaptor.getDensityIndependentValue(32);
    loginLP.addRule(RelativeLayout.CENTER_VERTICAL);
    loginLP.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    mLoginBtn.setLayoutParams(loginLP);
    mTopBanner.addView(mLoginBtn);
  }
Beispiel #2
0
  private void createButtons(Context context) {
    int panelWidth = LayoutUtil.getNavigationPanelWidth();
    int smallMargin = DensityAdaptor.getDensityIndependentValue(1);
    int buttonSideLength = (panelWidth - smallMargin * 3) / 2;
    int topOffset = LayoutUtil.getGalleryTopPanelHeight();

    //		ImageView crossSeparator = new ImageView(context);
    //		crossSeparator.setImageResource(R.drawable.cross_separator);
    //		LayoutParams crossSeparatorLP = new LayoutParams(LayoutParams.WRAP_CONTENT,
    // LayoutParams.WRAP_CONTENT);
    //		crossSeparatorLP.leftMargin = (panelWidth - DensityAdaptor.getDensityIndependentValue(100))
    // / 2;
    //		crossSeparatorLP.topMargin = DensityAdaptor.getDensityIndependentValue(120);
    //		crossSeparator.setLayoutParams(crossSeparatorLP);
    //		this.addView(crossSeparator);

    mSearchBtn = new SquareButton(context, R.drawable.search_140);
    RelativeLayout.LayoutParams searchBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    searchBtnLP.leftMargin = smallMargin;
    searchBtnLP.topMargin = topOffset + smallMargin;
    searchBtnLP.width = searchBtnLP.height = buttonSideLength;
    mSearchBtn.setLayoutParams(searchBtnLP);
    this.addView(mSearchBtn);

    mGalleryBtn = new SquareButton(context, R.drawable.gallery_browse_140);
    RelativeLayout.LayoutParams galleryBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    galleryBtnLP.leftMargin = smallMargin * 2 + buttonSideLength;
    galleryBtnLP.topMargin = searchBtnLP.topMargin;
    galleryBtnLP.width = galleryBtnLP.height = buttonSideLength;
    mGalleryBtn.setLayoutParams(galleryBtnLP);
    this.addView(mGalleryBtn);

    mMessageBtn = new SquareButton(context, R.drawable.message_140);
    RelativeLayout.LayoutParams messageBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    messageBtnLP.leftMargin = searchBtnLP.leftMargin;
    messageBtnLP.topMargin = topOffset + smallMargin * 2 + buttonSideLength;
    messageBtnLP.width = messageBtnLP.height = buttonSideLength;
    mMessageBtn.setLayoutParams(messageBtnLP);
    this.addView(mMessageBtn);

    mHelpBtn = new SquareButton(context, R.drawable.question_140);
    RelativeLayout.LayoutParams helpBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    helpBtnLP.leftMargin = galleryBtnLP.leftMargin;
    helpBtnLP.topMargin = messageBtnLP.topMargin;
    helpBtnLP.width = helpBtnLP.height = buttonSideLength;
    mHelpBtn.setLayoutParams(helpBtnLP);
    this.addView(mHelpBtn);

    // Sign up
    mSignUpBtn = new HaloButton(mContext, R.drawable.register);
    mSignUpBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            HomeActivity.getApp().toggleSignUpPanel(true);
          }
        });

    RelativeLayout.LayoutParams regBtnLP =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    regBtnLP.topMargin = DensityAdaptor.getDensityIndependentValue(150);
    regBtnLP.addRule(RelativeLayout.CENTER_HORIZONTAL);
    this.addView(mSignUpBtn, regBtnLP);
  }