当前位置: 首页>>代码示例>>Java>>正文


Java HorizontalScrollView.LayoutParams方法代码示例

本文整理汇总了Java中android.widget.HorizontalScrollView.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java HorizontalScrollView.LayoutParams方法的具体用法?Java HorizontalScrollView.LayoutParams怎么用?Java HorizontalScrollView.LayoutParams使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.HorizontalScrollView的用法示例。


在下文中一共展示了HorizontalScrollView.LayoutParams方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMeasure

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int width = ConversionUtils.getPixelsFromDp(40) * getChildCount(), height = getMeasuredHeight();
    setMeasuredDimension(width, height);

    HorizontalScrollView.LayoutParams layoutParams = (HorizontalScrollView.LayoutParams) getLayoutParams();
    if (layoutParams != null && getParent() != null && getParent() instanceof View) {
        if (((View) getParent()).getMeasuredWidth() > width)
            layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
        else layoutParams.gravity = GravityCompat.START;
        setLayoutParams(layoutParams);
    }
}
 
开发者ID:TheAndroidMaster,项目名称:Metronome-Android,代码行数:15,代码来源:EmphasesLayout.java

示例2: init

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
private void init() {
    HorizontalScrollView.LayoutParams params = new LayoutParams(-1, -1);
    mLinearLayout = new LinearLayout(getContext());
    mLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
    mLinearLayout.setBackgroundColor(0xffffffff);
    addView(mLinearLayout, params);
    mTimer = new Timer();
}
 
开发者ID:Fansvaer,项目名称:LuPengWeather,代码行数:9,代码来源:PagerIndecator.java

示例3: TabLayout

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  // ThemeUtils.checkAppCompatTheme(context);

  // Disable the Scroll Bar
  setHorizontalScrollBarEnabled(false);

  // Add the TabStrip
  mTabStrip = new SlidingTabStrip(context);
      super.addView(mTabStrip, 0, new HorizontalScrollView.LayoutParams(
          LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

      TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout,
              defStyleAttr, R.style.Widget_Design_TabLayout);

  mTabStrip.setSelectedIndicatorHeight(
      a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0));
  mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0));

      mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a
              .getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0);
      mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart,
              mTabPaddingStart);
      mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop,
              mTabPaddingTop);
      mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd,
              mTabPaddingEnd);
      mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom,
              mTabPaddingBottom);

      mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance,
              R.style.TextAppearance_Design_Tab);

  // Text colors/sizes come from the text appearance first
  final TypedArray ta =
      context.obtainStyledAttributes(
          mTabTextAppearance, R.styleable.TextAppearance);
  try {
    mTabTextSize =
        ta.getDimensionPixelSize(
            R.styleable.TextAppearance_android_textSize, 0);
    mTabTextColors =
        ta.getColorStateList(
            R.styleable.TextAppearance_android_textColor);
  } finally {
    ta.recycle();
  }

  if (a.hasValue(R.styleable.TabLayout_tabTextColor)) {
    // If we have an explicit text color set, use it instead
    mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor);
  }

  if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) {
    // We have an explicit selected text color set, so we need to make merge it with the
    // current colors. This is exposed so that developers can use theme attributes to set
    // this (theme attrs in ColorStateLists are Lollipop+)
    final int selected = a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0);
    mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected);
  }

      mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth,
              INVALID_WIDTH);
      mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth,
              INVALID_WIDTH);
  mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0);
  mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0);
  mMode = a.getInt(R.styleable.TabLayout_tabMode, MODE_FIXED);
  mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, GRAVITY_FILL);
  a.recycle();

  // TODO add attr for these
  final Resources res = getResources();
  mTabTextMultiLineSize = res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line);
  mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width);

  // Now apply the tab mode and gravity
  applyModeAndGravity();
}
 
开发者ID:commonsguy,项目名称:cwac-crossport,代码行数:81,代码来源:TabLayout.java

示例4: TabLayout

import android.widget.HorizontalScrollView; //导入方法依赖的package包/类
public TabLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    ThemeUtils.checkAppCompatTheme(context);

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);

    // Add the TabStrip
    mTabStrip = new SlidingTabStrip(context);
    super.addView(mTabStrip, 0, new HorizontalScrollView.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabLayout,
            defStyleAttr, R.style.Widget_Design_TabLayout);

    mTabStrip.setSelectedIndicatorHeight(
            a.getDimensionPixelSize(R.styleable.TabLayout_tabIndicatorHeight, 0));
    mTabStrip.setSelectedIndicatorColor(a.getColor(R.styleable.TabLayout_tabIndicatorColor, 0));

    mTabPaddingStart = mTabPaddingTop = mTabPaddingEnd = mTabPaddingBottom = a
            .getDimensionPixelSize(R.styleable.TabLayout_tabPadding, 0);
    mTabPaddingStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingStart,
            mTabPaddingStart);
    mTabPaddingTop = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingTop,
            mTabPaddingTop);
    mTabPaddingEnd = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingEnd,
            mTabPaddingEnd);
    mTabPaddingBottom = a.getDimensionPixelSize(R.styleable.TabLayout_tabPaddingBottom,
            mTabPaddingBottom);

    mTabTextAppearance = a.getResourceId(R.styleable.TabLayout_tabTextAppearance,
            R.style.TextAppearance_Design_Tab);

    // Text colors/sizes come from the text appearance first
    final TypedArray ta = context.obtainStyledAttributes(mTabTextAppearance,
            R.styleable.TextAppearance);
    try {
        mTabTextSize = ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, 0);
        mTabTextColors = ta.getColorStateList(R.styleable.TextAppearance_android_textColor);
    } finally {
        ta.recycle();
    }

    if (a.hasValue(R.styleable.TabLayout_tabTextColor)) {
        // If we have an explicit text color set, use it instead
        mTabTextColors = a.getColorStateList(R.styleable.TabLayout_tabTextColor);
    }

    if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) {
        // We have an explicit selected text color set, so we need to make merge it with the
        // current colors. This is exposed so that developers can use theme attributes to set
        // this (theme attrs in ColorStateLists are Lollipop+)
        final int selected = a.getColor(R.styleable.TabLayout_tabSelectedTextColor, 0);
        mTabTextColors = createColorStateList(mTabTextColors.getDefaultColor(), selected);
    }

    mRequestedTabMinWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMinWidth,
            INVALID_WIDTH);
    mRequestedTabMaxWidth = a.getDimensionPixelSize(R.styleable.TabLayout_tabMaxWidth,
            INVALID_WIDTH);
    mTabBackgroundResId = a.getResourceId(R.styleable.TabLayout_tabBackground, 0);
    mContentInsetStart = a.getDimensionPixelSize(R.styleable.TabLayout_tabContentStart, 0);
    mMode = a.getInt(R.styleable.TabLayout_tabMode, MODE_FIXED);
    mTabGravity = a.getInt(R.styleable.TabLayout_tabGravity, GRAVITY_FILL);
    a.recycle();

    // TODO add attr for these
    final Resources res = getResources();
    mTabTextMultiLineSize = res.getDimensionPixelSize(R.dimen.design_tab_text_size_2line);
    mScrollableTabMinWidth = res.getDimensionPixelSize(R.dimen.design_tab_scrollable_min_width);

    // Now apply the tab mode and gravity
    applyModeAndGravity();
}
 
开发者ID:GigigoGreenLabs,项目名称:permissionsModule,代码行数:76,代码来源:TabLayout.java


注:本文中的android.widget.HorizontalScrollView.LayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。