コード例 #1
0
  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;
  }
コード例 #2
0
 @Override
 public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
   int leftValue = progress;
   int rightValue = seekBar.getMax() - progress;
   // настраиваем вес
   lParams1.weight = leftValue;
   lParams2.weight = rightValue;
   // в текст кнопок пишем значения переменных
   btn1.setText(String.valueOf(leftValue));
   btn2.setText(String.valueOf(rightValue));
 }
コード例 #3
0
  private View generateView(int i) {

    LinearLayout.LayoutParams layoutParams =
        new LinearLayout.LayoutParams(0, LayoutParams.FILL_PARENT);
    if (i == -1 || i == list.size()) {
      layoutParams.weight = 1.5f;
    } else {
      layoutParams.weight = 1;
    }
    View v = new View(activity);
    v.setLayoutParams(layoutParams);
    return v;
  }
コード例 #4
0
    private LinearLayout getView(int position, Context context) {
      LinearLayout ll = new LinearLayout(context);
      ll.setOrientation(LinearLayout.VERTICAL);
      int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
      ll.setPadding(dp_5, dp_5, dp_5, dp_5);

      ImageView iv = new ImageView(context);
      iv.setScaleType(ScaleType.CENTER_INSIDE);
      LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(iconWidth, iconWidth);
      lpIv.gravity = Gravity.CENTER_HORIZONTAL;
      iv.setLayoutParams(lpIv);
      iv.setImageBitmap(getIcon(platforms[position]));
      ll.addView(iv);

      TextView tv = new TextView(context);
      tv.setTextColor(0xffffffff);
      tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
      tv.setSingleLine();
      tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
      LinearLayout.LayoutParams lpTv =
          new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      lpTv.weight = 1;
      tv.setLayoutParams(lpTv);
      tv.setText(getName(platforms[position]));
      ll.addView(tv);

      return ll;
    }
コード例 #5
0
  public LinearLayout crearImagen(Bitmap bitmap, final int nIdFoto) {
    ImageView ivImagen = new ImageView(this);

    LinearLayout linear_contenedorRegistro = (LinearLayout) new LinearLayout(this);
    linear_contenedorRegistro.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.setMargins(0, 0, 0, 0);
    lp.weight = 1;
    linear_contenedorRegistro.setLayoutParams(lp);
    linear_contenedorRegistro.setPadding(2, 2, 2, 2);

    if (bitmap != null) {
      // android:adjustViewBounds
      ivImagen.setImageBitmap(RotateBitmap(bitmap, 90));
      ivImagen.setAdjustViewBounds(true);

      ivImagen.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
              // TODO Auto-generated method stub
              irPreview(nIdFoto);
            }
          });
    }

    linear_contenedorRegistro.addView(ivImagen);

    return linear_contenedorRegistro;
  }
コード例 #6
0
  @Override
  protected View onCreateView(ViewGroup parent) {

    LinearLayout layout = new LinearLayout(getContext());
    LinearLayout.LayoutParams params1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    // params1.gravity = Gravity.LEFT;
    params1.weight = 1.0f;
    layout.setPadding(15, 10, 10, 10);
    layout.setOrientation(LinearLayout.HORIZONTAL);
    TextView view = new TextView(getContext());
    view.setText(R.string.rerun_setup_wizard);
    // view.setTextSize(18);
    // view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    view.setTextAppearance(getContext(), android.R.style.TextAppearance_Large);
    // view.setGravity(Gravity.LEFT);
    view.setLayoutParams(params1);

    this.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference arg0) {
            getContext().startActivity(new Intent(getContext(), WizardActivity.class));
            return true;
          }
        });

    layout.addView(view);
    layout.setId(android.R.id.widget_frame);
    return layout;
  }
コード例 #7
0
 /** 图片循环 */
 private void initViewPager() {
   ViewGroup.LayoutParams mViewPagerlayoutParams = mViewPager.getLayoutParams();
   if (mViewPagerlayoutParams != null) {
     mViewPagerlayoutParams.width = Misc.getScreenDisplay(this)[0];
     mViewPagerlayoutParams.height = (int) (mViewPagerlayoutParams.width);
     mViewPager.setLayoutParams(mViewPagerlayoutParams);
   }
   mViewPager.setAdapter(new ProductDetailPicAdapter2(this, product.getImgList()));
   mViewPager.setOnPageChangeListener(this);
   // 设置布局参数
   LinearLayout.LayoutParams params =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int marginParam = Misc.dip2px(this, 10) / 2;
   llytPagerPoiner.removeAllViewsInLayout();
   for (int i = 0; i < product.getImgList().size(); i++) {
     // 设置按钮属性
     View item = new ImageView(this);
     item.setBackgroundResource(R.drawable.recommend_gallery);
     item.setTag(String.valueOf(i));
     // item.setOnClickListener(parentActivity);
     params.setMargins(marginParam, 0, marginParam, 0);
     params.weight = 1;
     llytPagerPoiner.addView(item, params);
   }
   llytPagerPoiner.getChildAt(0).setBackgroundResource(R.drawable.recommend_gallery_select);
 }
コード例 #8
0
    // Override QuestionWidget's add question text. Build it the same
    // but add it to the questionLayout
    protected void addQuestionText(FormEntryPrompt p) {

        // Add the text view. Textview always exists, regardless of whether there's text.
    	TextView questionText = new TextView(getContext());
        questionText.setText(p.getLongText());
        questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize);
        questionText.setTypeface(null, Typeface.BOLD);
        questionText.setPadding(0, 0, 0, 7);
        questionText.setId(QuestionWidget.newUniqueId()); // assign random id

        // Wrap to the size of the parent view
        questionText.setHorizontallyScrolling(false);

        if (p.getLongText() == null) {
            questionText.setVisibility(GONE);
        }

        // Put the question text on the left half of the screen
        LinearLayout.LayoutParams labelParams =
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        labelParams.weight = 1;

        questionLayout = new LinearLayout(getContext());
        questionLayout.setOrientation(LinearLayout.HORIZONTAL);

        questionLayout.addView(questionText, labelParams);
    }
コード例 #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    generateShuffle();

    mainLayout = (LinearLayout) findViewById(R.id.activity_main_linear_layout);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    params.weight = 1f;
    for (int i = 0; i < 4; i++) {
      LinearLayout row = new LinearLayout(this);
      // row.setOrientation(LinearLayout.HORIZONTAL);
      for (int j = 0; j < 3; j++) {
        ImageView imageView = new ImageView(this);
        imageView.setTag(tag++);
        imageView.setOnClickListener(this);
        imageView.setImageResource(R.drawable.card_back);
        row.addView(imageView, params);
      }
      mainLayout.addView(row, params);
    }
  }
コード例 #10
0
  private void addTemporaryTab() {
    for (int i = 0; i < 3; i++) {
      CharSequence title = null;
      if (i == 0) title = "TAB ONE";
      else if (i == 1) title = "TAB TWO";
      else if (i == 2) title = "TAB THREE";

      CheckedTextView tv = new CheckedTextView(getContext());
      tv.setCheckMarkDrawable(null);
      tv.setText(title);
      tv.setGravity(Gravity.CENTER);
      tv.setTextAppearance(getContext(), mTextApperance);
      tv.setSingleLine(true);
      tv.setEllipsize(TruncateAt.END);
      tv.setTag(i);
      tv.setChecked(i == 0);
      if (mMode == MODE_SCROLL) {
        tv.setPadding(mTabPadding, 0, mTabPadding, 0);
        mTabContainer.addView(
            tv,
            new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
      } else if (mMode == MODE_FIXED) {
        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
        params.weight = 1f;
        mTabContainer.addView(tv, params);
      }
    }
  }
コード例 #11
0
 private void populateTabStrip() {
   final PagerAdapter adapter = mViewPager.getAdapter();
   final View.OnClickListener tabClickListener = new TabClickListener();
   for (int i = 0; i < adapter.getCount(); i++) {
     View tabView = null;
     TextView tabTitleView = null;
     if (mTabViewLayoutId != 0) {
       // If there is a custom tab view layout id set, try and inflate it
       tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
       tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
     }
     if (tabView == null) {
       tabView = createDefaultTabView(getContext());
     }
     if (tabTitleView == null && TextView.class.isInstance(tabView)) {
       tabTitleView = (TextView) tabView;
     }
     if (mDistributeEvenly) {
       LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
       lp.width = 0;
       lp.weight = 1;
     }
     tabTitleView.setText(adapter.getPageTitle(i));
     tabView.setOnClickListener(tabClickListener);
     String desc = mContentDescriptions.get(i, null);
     if (desc != null) {
       tabView.setContentDescription(desc);
     }
     mTabStrip.addView(tabView);
     if (i == mViewPager.getCurrentItem()) {
       tabView.setSelected(true);
     }
   }
 }
コード例 #12
0
 private void setWeight(View v, int id, float w) {
   View vv = v.findViewById(id);
   LinearLayout.LayoutParams xxx =
       (android.widget.LinearLayout.LayoutParams) vv.getLayoutParams();
   xxx.weight = w;
   vv.setLayoutParams(xxx);
 }
コード例 #13
0
  private void populateTabStrip() {
    final PagerAdapter adapter = viewPager.getAdapter();

    for (int i = 0; i < adapter.getCount(); i++) {

      final View tabView =
          (tabProvider == null)
              ? createDefaultTabView(adapter.getPageTitle(i))
              : tabProvider.createTabView(tabStrip, i, adapter);

      if (tabView == null) {
        throw new IllegalStateException("tabView is null.");
      }

      if (distributeEvenly) {
        LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        lp.width = 0;
        lp.weight = 1;
      }

      if (internalTabClickListener != null) {
        tabView.setOnClickListener(internalTabClickListener);
      }

      tabStrip.addView(tabView);

      if (i == viewPager.getCurrentItem()) {
        tabView.setSelected(true);
      }
    }
  }
コード例 #14
0
ファイル: SegmentButton.java プロジェクト: bozuko/android
  public void addSegment(String title) {
    DisplayMetrics metrics = new DisplayMetrics();
    ((Activity) getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);

    ToggleButton b = new ToggleButton(getContext());
    b.setText(title);
    b.setTextOff(title);
    b.setTextOn(title);
    b.setTextColor(Color.WHITE);
    b.setTypeface(Typeface.DEFAULT_BOLD);
    b.setMinimumWidth((int) (40 * metrics.density));
    if (mSwitches.size() == 0) {
      b.setBackgroundResource(mLeftDrawable);
      b.setEnabled(false);
      b.setChecked(true);
    } else {
      if (mSwitches.size() > 1) {
        ToggleButton temp = mSwitches.get(mSwitches.size() - 1);
        temp.setBackgroundResource(mMidDrawable);
      }

      b.setBackgroundResource(mRightDrawable);
    }

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    params.weight = 0.1f;
    params.gravity = Gravity.CENTER;
    b.setLayoutParams(params);

    b.setOnCheckedChangeListener(this);

    mSwitches.add(b);
    addView(b);
  }
コード例 #15
0
  public TipTextView(Context context, AttributeSet attrs) {
    super(context, attrs);

    /* 这里取得declare-styleable集合 */
    TypedArray typeArray = context.obtainStyledAttributes(attrs, R.styleable.TipTextView);
    /* 这里从集合里取出相对应的属性值,第二参数是如果使用者没用配置该属性时所用的默认值 */
    text = typeArray.getString(R.styleable.TipTextView_text);

    textPosition = typeArray.getInt(R.styleable.TipTextView_textPosition, textPosition);
    // float textSize = typeArray.getDimension(R.styleable.MyView_textSize,
    // 36);
    // mString = typeArray.getString(R.styleable.MyView_text);
    // /* 设置自己的类成员变量 */
    // mPaint.setTextSize(textSize);
    // mPaint.setColor(textColor);
    /* 关闭资源 */
    typeArray.recycle();
    LinearLayout.LayoutParams params;
    int lineHeight = (int) (getResources().getDisplayMetrics().density * 3);

    if (textPosition >= 0) {
      params = new LayoutParams(0, lineHeight);

      View view = new View(context);
      if (lineBackground > -1) view.setBackgroundResource(lineBackground);
      params.weight = 1;

      this.addView(view, params);
    }
    TextView tv = new TextView(context);
    tv.setText(text);

    params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    this.addView(tv, params);

    if (textPosition <= 0) {
      params = new LayoutParams(0, lineHeight);

      View view = new View(context);
      if (lineBackground > -1) view.setBackgroundResource(lineBackground);
      params.weight = 1;

      this.addView(view, params);
    }
    this.setGravity(Gravity.CENTER);
  }
コード例 #16
0
ファイル: FollowList.java プロジェクト: cg8530/LDXY
  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);
  }
コード例 #17
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   View defaultView = super.onCreateView(inflater, container, savedInstanceState);
   LinearLayout.LayoutParams p1 =
       new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT);
   p1.weight = 0.33f;
   defaultView.setLayoutParams(p1);
   return defaultView;
 }
コード例 #18
0
ファイル: P1ActionBar.java プロジェクト: BurtKim/p1-android
 /**
  * Sets right view to arbitrary view
  *
  * @param view
  */
 public void setRightView(View view) {
   android.widget.LinearLayout.LayoutParams pl =
       new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   if (view instanceof UserPictureView) pl.rightMargin = 0;
   else pl.rightMargin = mLayout.getPaddingLeft();
   pl.weight = 1;
   pl.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
   mLayout.addView(view, -1, pl);
   mLayout.setVisibility(View.VISIBLE);
 }
コード例 #19
0
  /**
   * Creates the widget that holds the content of a tab.
   *
   * @param activity Activity to create the widgets in.
   * @return the widget that holds the content of a tab.
   */
  private FrameLayout createTabContent(Activity activity) {
    FrameLayout tabContent = new FrameLayout(activity);
    tabContent.setId(android.R.id.tabcontent);
    LinearLayout.LayoutParams tabContentParams =
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0);
    tabContentParams.weight = 1;
    tabContent.setLayoutParams(tabContentParams);

    return tabContent;
  }
コード例 #20
0
  /**
   * Creates the widget that holds the actual tabs.
   *
   * @param activity Activity to create the widgets in.
   * @return the widget that holds the actual tabs.
   */
  private TabWidget createTabWidget(Activity activity) {
    TabWidget tabWidget = new TabWidget(activity);
    tabWidget.setId(android.R.id.tabs);
    LinearLayout.LayoutParams tabWidgetParams =
        new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
    tabWidgetParams.weight = 0;
    tabWidget.setLayoutParams(tabWidgetParams);

    return tabWidget;
  }
コード例 #21
0
  public void onClick(View v) {

    drawerLL = First.drawerLL;
    fragmentLL = First.fragmentLL;
    parentFragment = First.parentFragment;

    if (check) {
      check = false;

      LinearLayout.LayoutParams childParam1 =
          new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
      childParam1.weight = 0.0f;
      drawerLL.setLayoutParams(childParam1);

      LinearLayout.LayoutParams childParam2 =
          new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
      childParam2.weight = 1.0f;
      fragmentLL.setLayoutParams(childParam2);
      parentFragment.removeAllViews();
      parentFragment.setWeightSum(1f);
      parentFragment.addView(drawerLL);
      parentFragment.addView(fragmentLL);

    } else {
      check = true;
      LinearLayout.LayoutParams childParam1 =
          new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
      childParam1.weight = 0.3f;
      // childParam1.bottomMargin = 20;
      drawerLL.setLayoutParams(childParam1);

      LinearLayout.LayoutParams childParam2 =
          new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
      childParam2.weight = 0.7f;
      // childParam2.bottomMargin = 20;
      fragmentLL.setLayoutParams(childParam2);

      parentFragment.removeAllViews();
      parentFragment.setWeightSum(1f);
      parentFragment.addView(drawerLL);
      parentFragment.addView(fragmentLL);
    }
  }
コード例 #22
0
  // 进新浪微博、腾讯微博、Facebook和Twitter支持At功能
  private LinearLayout getAtLine(String platform) {
    if ("SinaWeibo".equals(platform)
        || "TencentWeibo".equals(platform)
        || "Facebook".equals(platform)
        || "Twitter".equals(platform)) {
      LinearLayout llAt = new LinearLayout(getContext());
      LinearLayout.LayoutParams lpAt =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lpAt.rightMargin = dipToPx(getContext(), 4);
      lpAt.gravity = Gravity.LEFT | Gravity.BOTTOM;
      lpAt.weight = 1;
      llAt.setLayoutParams(lpAt);
      llAt.setOnClickListener(
          new OnClickListener() {
            public void onClick(View v) {
              FollowList subPage = new FollowList();
              String platform = String.valueOf(reqData.get("platform"));
              subPage.setPlatform(ShareSDK.getPlatform(platform));
              subPage.showForResult(activity, null, EditPage.this);
            }
          });

      TextView tvAt = new TextView(getContext());
      int resId = getBitmapRes(activity, "btn_back_nor");
      if (resId > 0) {
        tvAt.setBackgroundResource(resId);
      }
      int dp_32 = dipToPx(getContext(), 32);
      tvAt.setLayoutParams(new LinearLayout.LayoutParams(dp_32, dp_32));
      tvAt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
      tvAt.setText("@");
      int dp_2 = dipToPx(getContext(), 2);
      tvAt.setPadding(0, 0, 0, dp_2);
      tvAt.setTypeface(Typeface.DEFAULT_BOLD);
      tvAt.setTextColor(0xff000000);
      tvAt.setGravity(Gravity.CENTER);
      llAt.addView(tvAt);

      TextView tvName = new TextView(getContext());
      tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
      tvName.setTextColor(0xff000000);
      resId = getStringRes(activity, "list_friends");
      String text = getContext().getString(resId, getName(platform));
      tvName.setText(text);
      LinearLayout.LayoutParams lpName =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      lpName.gravity = Gravity.CENTER_VERTICAL;
      tvName.setLayoutParams(lpName);
      llAt.addView(tvName);

      return llAt;
    }

    return null;
  }
コード例 #23
0
ファイル: PageTab.java プロジェクト: 601367322/dog
 public TextView createTextView(String str) {
   TextView tv = new TextView(getActivity());
   LinearLayout.LayoutParams lp =
       new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.FILL_PARENT);
   lp.weight = 1;
   tv.setGravity(Gravity.CENTER);
   tv.setLayoutParams(lp);
   tv.setTextSize(14);
   tv.setTextColor(getResources().getColor(R.color.nav_bar_text));
   tv.setText(str);
   return tv;
 }
コード例 #24
0
  private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
      View tabView = null;
      TextView tabTitleView = null;

      if (mTabViewLayoutId != 0) {
        // If there is a custom tab view layout id set, try and inflate it
        tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
        LinearLayout.LayoutParams loparams = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        loparams.weight = 1;
        //                loparams.height = 50;
        //                loparams.gravity = Gravity.CENTER;
        tabView.setLayoutParams(loparams);
        tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        tabTitleView.setLayoutParams(
            new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1f));
      }

      if (tabView == null) {
        tabView = createDefaultTabView(getContext());
        LinearLayout.LayoutParams loparams = (LinearLayout.LayoutParams) tabView.getLayoutParams();
        loparams.weight = 1;
        //                loparams.height = 50;
        //                loparams.gravity = Gravity.CENTER;
        tabView.setLayoutParams(loparams);
      }

      if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        tabTitleView = (TextView) tabView;
      }

      tabTitleView.setText(adapter.getPageTitle(i));
      tabView.setOnClickListener(tabClickListener);

      mTabStrip.addView(tabView);
    }
  }
コード例 #25
0
    @Override
    public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
      if (!b) return;

      float diff = item.weight - progress;
      item.weight = progress;
      item.isTouched = true;
      LinearLayout.LayoutParams params =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      params.weight = progress;
      findViewById(0x00001000 + item.position).setLayoutParams(params);

      helper.recountWeights(item.position, diff);
      // change weight of other elements

      // update other views
      LinearLayout.LayoutParams params1 =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      for (WeightItem weightItem : helper.itemsList) {
        TextView weTxt = (TextView) findViewById(0x00002000 + weightItem.position);
        weTxt.setText("weight of item " + weightItem.position + " w = " + weightItem.weight);
        if (weightItem.position == item.position) {
          continue;
        }

        params1.weight = weightItem.weight;
        findViewById(0x00001000 + weightItem.position).setLayoutParams(params1);
      }

      //            TextView weightOfItemTxt = (TextView) findViewById(0x00002000 + item.position);
      //            weightOfItemTxt.setText("weight of item " + item.position + " w = " +
      // item.weight);

      total.setText("total weightSum = " + helper.getTotalWeightSum());

      weightView.invalidate();
      changeView.invalidate();
    }
コード例 #26
0
  private void initListView() {
    mPatchesAdapter = new PatchesAdapter(mContext);
    mPatchList = (ListView) findViewById(R.id.patch_list);

    TextView emptyView = new TextView(mContext);
    LinearLayout.LayoutParams lparam =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    lparam.weight = 1;
    emptyView.setLayoutParams(lparam);
    emptyView.setText(getString(R.string.empty));
    emptyView.setVisibility(View.GONE);
    ((ViewGroup) mPatchList.getParent()).addView(emptyView, 2);
    mPatchList.setEmptyView(emptyView);

    mPatchList.setFastScrollEnabled(true);
    mPatchList.setDivider(new ColorDrawable(0xff777777));
    mPatchList.setDividerHeight(1);
    mPatchList.setAdapter(mPatchesAdapter);
    mPatchList.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            FPatch p = mPatchesAdapter.getItem(position);
            mInfoDialog.show(
                getFragmentManager(),
                p.packageName,
                "apkPath=" + p.apkPath + "\ntargetJar=" + p.targetJar);
          }
        });

    mPatchList.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            FPatch p = mPatchesAdapter.getItem(position);
            Intent intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
            intent.setData(android.net.Uri.fromParts("package", p.packageName, null));
            startActivity(intent);
            return true;
          }
        });

    refreshList();

    //		mPatchesAdapter.sort(new java.util.Comparator<FPatch>() {
    //			@Override
    //			public int compare(FPatch lhs, FPatch rhs) {
    //				return lhs.appName.compareTo(rhs.appName);
    //			}
    //		});
  }
コード例 #27
0
ファイル: MainActivity.java プロジェクト: mim3009/lessons
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // создание LinearLayout
    LinearLayout linLayout = new LinearLayout(this);
    // установим вертикальную ориентацию
    linLayout.setOrientation(LinearLayout.VERTICAL);
    // создаем LayoutParams
    LayoutParams linLayoutParam =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    // устанавливаем linLayout как корневой элемент экрана
    setContentView(linLayout, linLayoutParam);

    LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    TextView tv = new TextView(this);
    tv.setText("TextView");
    tv.setLayoutParams(lpView);
    linLayout.addView(tv);

    Button btn = new Button(this);
    btn.setText("Button");
    linLayout.addView(btn, lpView);

    LinearLayout.LayoutParams leftMarginParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    leftMarginParams.leftMargin = 50;

    Button btn1 = new Button(this);
    btn1.setText("Button1");
    linLayout.addView(btn1, leftMarginParams);

    LinearLayout.LayoutParams rightGravityParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    rightGravityParams.gravity = Gravity.RIGHT;

    Button btn2 = new Button(this);
    btn2.setText("Button2");
    linLayout.addView(btn2, rightGravityParams);

    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.weight = 1;

    Button b = new Button(this);
    b.setText("bbbb");
    linLayout.addView(b, lp);

    EditText et = new EditText(this);
    et.setText("dd");
    linLayout.addView(et, lp);
  }
コード例 #28
0
 public void setVerticalEqually() {
   for (Pair<View, View> tab : tabs) {
     ViewGroup.LayoutParams params = tab.first.getLayoutParams();
     if (params instanceof LinearLayout.LayoutParams) {
       LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) params;
       lp.weight = 1;
       lp.height = 0;
       lp.width = -1;
       tab.first.setLayoutParams(lp);
     }
   }
   onGlobalLayout();
 }
コード例 #29
0
 private void centerButton(Button button) {
   LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) button.getLayoutParams();
   params.gravity = Gravity.CENTER_HORIZONTAL;
   params.weight = 0.5f;
   button.setLayoutParams(params);
   View leftSpacer = mWindow.findViewById(R.id.leftSpacer);
   if (leftSpacer != null) {
     leftSpacer.setVisibility(View.VISIBLE);
   }
   View rightSpacer = mWindow.findViewById(R.id.rightSpacer);
   if (rightSpacer != null) {
     rightSpacer.setVisibility(View.VISIBLE);
   }
 }
コード例 #30
0
  private void addWeightElement() {
    //        currentItemsCnt++;
    WeightItem item = new WeightItem();
    item.position = helper.itemsList.size();
    item.weight = 100 / currentItemsCnt;
    helper.itemsList.add(item);

    TextView text = new TextView(this);
    text.setText("pos" + item.position);

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.weight = item.weight;
    text.setLayoutParams(params);
    text.setId(0x00001000 + item.position);
    text.setBackgroundColor(
        Color.rgb(
            0xFF / (item.position + 1), 0x7F / (item.position + 1), 0xFF / (item.position + 1)));
    weightView.addView(text);

    // Liean container

    TextView seekText = new TextView(this);
    seekText.setText("pos " + item.position);
    seekText.setPadding(0, 0, 10, 0);
    SeekBar seekBar = new SeekBar(this);
    seekBar.setId(0x00001000 + item.position + 30);
    seekBar.setMax(100 / currentItemsCnt);
    seekBar.setOnSeekBarChangeListener(new SeekListener(item));
    seekBar.setPadding(0, 5, 0, 5);
    seekBar.setProgress(seekBar.getMax());

    LinearLayout linearLayout = new LinearLayout(this);
    //            LinearLayout.LayoutParams params = new
    // LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
    //                    ViewGroup.LayoutParams.WRAP_CONTENT);
    seekBar.setLayoutParams(params);
    linearLayout.addView(seekText);
    linearLayout.addView(seekBar);

    seekView.addView(linearLayout);

    TextView ttt = new TextView(this);

    ttt.setId(0x00002000 + item.position);
    ttt.setText("weight of item " + item.position + " w = " + item.weight);
    changeView.addView(ttt);
  }