Java Code Examples for android.widget.LinearLayout#setLayoutParams()

The following examples show how to use android.widget.LinearLayout#setLayoutParams() . 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: NavitationFollowScrollLayout.java    From NavigationBar with Apache License 2.0 6 votes vote down vote up
public NavitationFollowScrollLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.context = context;
    margleft = dip2px(context, 0);
    titleLayout = new LinearLayout(context);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
    titleLayout.setLayoutParams(layoutParams);
    titleLayout.setOrientation(LinearLayout.HORIZONTAL);
    titleLayout.setGravity(Gravity.CENTER_VERTICAL);

    LayoutParams layoutParams2 = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
    horizontalScrollView = new CusHorizontalScrollView(context);
    horizontalScrollView.addView(titleLayout, layoutParams2);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    addView(horizontalScrollView);
}
 
Example 2
Source File: MainActivity.java    From Building-Android-UIs-with-Custom-Views with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setLayoutParams(
            new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    OwnCustomView customView = new OwnCustomView.Builder(this)
            .topLeftColor(BRIGHT_RED)
            .topRightColor(BRIGHT_GREEN)
            .bottomLeftColor(BRIGHT_YELLOW)
            .bottomRightColor(BRIGHT_BLUE)
            .build();

    linearLayout.addView(customView);

    setContentView(linearLayout);
}
 
Example 3
Source File: FloorControllerView.java    From mapwize-ui-android with MIT License 6 votes vote down vote up
private void initLayout() {
    this.setVerticalScrollBarEnabled(false);
    viewSize = (int)getContext().getResources().getDimension(R.dimen.mapwize_ui_floor_button_size);
    linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(
            viewSize,
            LinearLayout.LayoutParams.WRAP_CONTENT
    ));
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setBackgroundColor(Color.TRANSPARENT);
    linearLayout.setVerticalGravity(Gravity.BOTTOM);
    /*linearLayout.setLayoutTransition(new LayoutTransition());
    setLayoutTransition(new LayoutTransition());
    getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
    linearLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);*/
    this.addView(linearLayout);
}
 
Example 4
Source File: VNTNumberPickerPreference.java    From VNTNumberPickerPreference with Apache License 2.0 6 votes vote down vote up
@Override
protected void onPrepareDialogBuilder(final Builder builder) {
    super.onPrepareDialogBuilder(builder);

    numberPicker = new NumberPicker(this.getContext());
    numberPicker.setMinValue(minValue);
    numberPicker.setMaxValue(maxValue);
    numberPicker.setValue(selectedValue);
    numberPicker.setWrapSelectorWheel(wrapSelectorWheel);
    numberPicker.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    final LinearLayout linearLayout = new LinearLayout(this.getContext());
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.addView(numberPicker);

    builder.setView(linearLayout);
}
 
Example 5
Source File: MonthViewPagerAdapter.java    From FlexibleCalendar with MIT License 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater inflater = LayoutInflater.from(context);
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    FlexibleCalendarGridAdapter adapter = dateAdapters.get(position);
    adapter.setOnDateClickListener(onDateCellItemClickListener);
    adapter.setMonthEventFetcher(monthEventFetcher);
    adapter.setCellViewDrawer(cellViewDrawer);

    GridView view = (GridView) inflater.inflate(R.layout.month_grid_layout, null);
    view.setTag(GRID_TAG_PREFIX + position);
    view.setAdapter(adapter);
    view.setVerticalSpacing(gridViewVerticalSpacing);
    view.setHorizontalSpacing(gridViewHorizontalSpacing);

    layout.addView(view);
    container.addView(layout);
    return layout;
}
 
Example 6
Source File: ViewPagerImageAdapter.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, final int position) {

    LinearLayout linearLayout = new LinearLayout(mContext);
    linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    ImageView iv = new ImageView(mContext);

    if (!TextUtils.isEmpty(indexImages.get(position).getImgPath())) {
        Glide.with(mContext).load(indexImages.get(position).getImgPath()).into(iv);
    }
    iv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(mContext, indexImages.get(position).getTitle(), Toast.LENGTH_SHORT).show();
        }
    });

    iv.setScaleType(ImageView.ScaleType.CENTER_CROP);

    linearLayout.addView(iv, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    container.addView(linearLayout);
    return linearLayout;
}
 
Example 7
Source File: BaseDialog.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public BaseDialog setCheckBoxName(List<String> list) {
    if (middleLayout.getChildCount() > 0) {
        middleLayout.removeAllViews();
    }
    for (String title :
            list) {
        TextView textView = new TextView(getContext());
        textView.setGravity(Gravity.START);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        layoutParams.weight = 1;
        textView.setLayoutParams(layoutParams);
        textView.setText(title);
        final CheckBox checkBox = new CheckBox(getContext());
        checkBox.setGravity(Gravity.END);
        LinearLayout.LayoutParams checkBoxLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        checkBoxLayout.weight = 1;
        checkBox.setLayoutParams(checkBoxLayout);
        LinearLayout linearLayout = new LinearLayout(getContext());
        LinearLayout.LayoutParams linearLayoutParam = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        linearLayout.setGravity(Gravity.CENTER_VERTICAL);
        linearLayout.setWeightSum(2);
        linearLayout.setLayoutParams(linearLayoutParam);
        linearLayout.addView(textView);
        linearLayout.addView(checkBox);
        middleLayout.addView(linearLayout);
    }
    return this;
}
 
Example 8
Source File: PendingFuncActivity.java    From QNotified with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean doOnCreate(Bundle bundle) {
    super.doOnCreate(bundle);
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams mmlp = new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    LinearLayout __ll = new LinearLayout(this);
    __ll.setOrientation(LinearLayout.VERTICAL);
    ViewGroup bounceScrollView = new BounceScrollView(this, null);
    bounceScrollView.setLayoutParams(mmlp);
    bounceScrollView.addView(ll, new ViewGroup.LayoutParams(MATCH_PARENT, WRAP_CONTENT));
    LinearLayout.LayoutParams fixlp = new LinearLayout.LayoutParams(MATCH_PARENT, dip2px(this, 48));
    RelativeLayout.LayoutParams __lp_l = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    int mar = (int) (dip2px(this, 12) + 0.5f);
    __lp_l.setMargins(mar, 0, mar, 0);
    __lp_l.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    __lp_l.addRule(RelativeLayout.CENTER_VERTICAL);
    RelativeLayout.LayoutParams __lp_r = new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
    __lp_r.setMargins(mar, 0, mar, 0);
    __lp_r.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    __lp_r.addRule(RelativeLayout.CENTER_VERTICAL);

    ll.addView(subtitle(this, "牙膏要一点一点挤, 显卡要一刀一刀切, PPT要一张一张放, 代码要一行一行写, 单个功能预计自出现在commit之日起, 三年内开发完毕"));

    ll.addView(newListItemSwitchStub(this, "强制使用默认字体", null, false));
    ll.addView(newListItemSwitchStub(this, "点一下赞20次", "仅限回赞界面, 与花Q等效", false));
    ll.addView(newListItemSwitchStub(this, "无视QQ电话与语音冲突", "允许在QQ电话时播放语音和短视频", false));
    ll.addView(newListItemSwitchStub(this, "QQ电话关麦时解除占用", "再开麦时如麦被其他程序占用可能崩溃", false));
    ll.addView(newListItemSwitchStub(this, "屏蔽好友热播", "隐藏动态里的好友热播", false));
    ll.addView(newListItemSwitchConfigStub(this, "屏蔽回执消息的通知", null, ConfigItems.qn_mute_talk_back, false));
    ll.addView(newListItemButton(this, "小尾巴", "请勿在多个模块同时开启小尾巴", "[无]", clickTheComing()));
    ll.addView(newListItemButton(this, "聊天图片自动接收原图", null, "禁用", clickTheComing()));
    ll.addView(newListItemButton(this, "强制原图发送聊天图片", null, "禁用", clickTheComing()));
    ll.addView(newListItemButton(this, "隐藏联系人", "和自带的\"隐藏会话\"有所不同", "0人", clickTheComing()));
    ll.addView(newListItemButton(this, "自定义本地头像", "仅本机生效", "禁用", clickTheComing()));
    ll.addView(newListItemButton(this, "高级通知设置", "通知展开, channel等", null, clickTheComing()));
    ll.addView(newListItemButton(this, "QQ电话睡眠模式", "仅保持连麦, 暂停消息接收, 减少电量消耗", null, clickTheComing()));
    ll.addView(newListItemSwitchStub(this, "禁用QQ公交卡", "如果QQ在后台会干扰NFC的话", false));
    ll.addView(newListItemButton(this, "AddFriendReq.sourceID", "自定义加好友来源", "[不改动]", clickTheComing()));
    ll.addView(newListItemButton(this, "DelFriendReq.delType", "只能为1或2", "[不改动]", clickTheComing()));
    ll.addView(newListItemSwitchStub(this, "隐藏聊天界面右侧滑条", "强迫症专用", false));

    __ll.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    this.setContentView(bounceScrollView);
    LinearLayout.LayoutParams _lp_fat = new LinearLayout.LayoutParams(MATCH_PARENT, 0);
    _lp_fat.weight = 1;
    //__ll.addView(bounceScrollView,_lp_fat);
    //sdlv.setBackgroundColor(0xFFAA0000)
    setTitle("咕咕咕");
    setContentBackgroundDrawable(ResUtils.skin_background);
    return true;
}
 
Example 9
Source File: AreaViewItem.java    From LibreTasks with Apache License 2.0 5 votes vote down vote up
/**
 * Create insert this object's {@link View} objects into {@code viewGroup}
 * 
 * @param initData
 *          data to be used for initializing the values in the {@link View} objects. Pass null for
 *          no data. Note that this should be an instance of {@link OmniArea}
 * @return the {@link View} object representing the underlying {@link OmniArea} object
 */
public View buildUI(DataType initData) {
  LinearLayout layout = new LinearLayout(mActivity);
  layout.setId(ID);
  layout.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  layout.setOrientation(LinearLayout.VERTICAL);

  if (initData != null) {
    OmniArea area = (OmniArea) initData;
    etAddress.setText(area.getUserInput());
    etDistance.setText(Double.toString(area.getProximityDistance()));
  }

  TextView tvAddress = new TextView(mActivity);
  tvAddress.setText(R.string.area_address);

  TextView tvDistance = new TextView(mActivity);
  tvDistance.setText(R.string.area_distance);

  layout.addView(tvAddress);
  layout.addView(etAddress);
  layout.addView(tvDistance);
  layout.addView(etDistance);

  return layout;
}
 
Example 10
Source File: TabsLayout.java    From Scrollable with Apache License 2.0 5 votes vote down vote up
private void init(Context context, AttributeSet attributeSet) {

        mInflater = LayoutInflater.from(context);

        mContainer = new LinearLayout(context);
        ((LinearLayout) mContainer).setOrientation(LinearLayout.HORIZONTAL);
        mContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
        mContainer.setLayoutTransition(new LayoutTransition());

        addView(mContainer);
    }
 
Example 11
Source File: ColumnActivity.java    From LiuAGeAndroid with MIT License 5 votes vote down vote up
/**
 * 创建移动的item对应的ViewGroup布局容器
 * 用于存放我们移动的View
 */
private ViewGroup getMoveViewGroup() {
    // window中最顶层的view
    ViewGroup moveViewGroup = (ViewGroup) getWindow().getDecorView();
    LinearLayout moveLinearLayout = new LinearLayout(this);
    moveLinearLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    moveViewGroup.addView(moveLinearLayout);
    return moveLinearLayout;
}
 
Example 12
Source File: CustomAlertDialog.java    From NIM_Android_UIKit with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.nim_easy_alert_dialog_with_listview);
    LinearLayout root = (LinearLayout) findViewById(R.id.easy_alert_dialog_layout);
    ViewGroup.LayoutParams params = root.getLayoutParams();
    params.width = (int) ScreenUtil.getDialogWidth();
    root.setLayoutParams(params);
    addFootView(root);
    titleView = findViewById(R.id.easy_dialog_title_view);
    if (titleView != null) {
        setTitleVisible(isTitleVisible);
    }
    titleTextView = (TextView) findViewById(R.id.easy_dialog_title_text_view);
    if (titleTextView != null) {
        setTitle(title);
    }
    titleBtn = (ImageButton) findViewById(R.id.easy_dialog_title_button);
    if (titleBtn != null) {
        setTitleBtnVisible(isTitleBtnVisible);
        setTitleBtnListener(titleListener);
    }
    listView = (ListView) findViewById(R.id.easy_dialog_list_view);
    if (itemSize > 0) {
        updateListView();
    }
}
 
Example 13
Source File: RapidFloatingActionContentLabelList.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void initInConstructor() {
    rfacItemDrawableSizePx = RFABTextUtil.dip2px(getContext(), RFABConstants.SIZE.RFAC_ITEM_DRAWABLE_SIZE_DP);

    contentView = new LinearLayout(getContext());
    contentView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    contentView.setOrientation(LinearLayout.VERTICAL);
    setRootView(contentView);
}
 
Example 14
Source File: CordovaActivity.java    From cordova-android-chromeview with Apache License 2.0 4 votes vote down vote up
/**
 * Shows the splash screen over the full Activity
 */
@SuppressWarnings("deprecation")
protected void showSplashScreen(final int time) {
    final CordovaActivity that = this;

    Runnable runnable = new Runnable() {
        public void run() {
            // Get reference to display
            Display display = getWindowManager().getDefaultDisplay();

            // Create the layout for the dialog
            LinearLayout root = new LinearLayout(that.getActivity());
            root.setMinimumHeight(display.getHeight());
            root.setMinimumWidth(display.getWidth());
            root.setOrientation(LinearLayout.VERTICAL);
            root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK));
            root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
                    ViewGroup.LayoutParams.FILL_PARENT, 0.0F));
            root.setBackgroundResource(that.splashscreen);
            
            // Create and show the dialog
            splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar);
            // check to see if the splash screen should be full screen
            if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN)
                    == WindowManager.LayoutParams.FLAG_FULLSCREEN) {
                splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                        WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }
            splashDialog.setContentView(root);
            splashDialog.setCancelable(false);
            splashDialog.show();

            // Set Runnable to remove splash screen just in case
            final Handler handler = new Handler();
            handler.postDelayed(new Runnable() {
                public void run() {
                    removeSplashScreen();
                }
            }, time);
        }
    };
    this.runOnUiThread(runnable);
}
 
Example 15
Source File: DropDownMenu.java    From AcgClub with MIT License 4 votes vote down vote up
public DropDownMenu(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  setOrientation(VERTICAL);

  //为DropDownMenu添加自定义属性
  int menuBackgroundColor = 0xffffffff;
  int underlineColor = 0xffcccccc;
  TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DropDownMenu);
  underlineColor = a.getColor(R.styleable.DropDownMenu_ddunderlineColor, underlineColor);
  dividerColor = a.getColor(R.styleable.DropDownMenu_dddividerColor, dividerColor);
  textSelectedColor = a.getColor(R.styleable.DropDownMenu_ddtextSelectedColor, textSelectedColor);
  textUnselectedColor = a
      .getColor(R.styleable.DropDownMenu_ddtextUnselectedColor, textUnselectedColor);
  menuBackgroundColor = a
      .getColor(R.styleable.DropDownMenu_ddmenuBackgroundColor, menuBackgroundColor);
  maskColor = a.getColor(R.styleable.DropDownMenu_ddmaskColor, maskColor);
  menuTextSize = a.getDimensionPixelSize(R.styleable.DropDownMenu_ddmenuTextSize, menuTextSize);
  menuSelectedIcon = a
      .getResourceId(R.styleable.DropDownMenu_ddmenuSelectedIcon, menuSelectedIcon);
  menuUnselectedIcon = a
      .getResourceId(R.styleable.DropDownMenu_ddmenuUnselectedIcon, menuUnselectedIcon);
  menuHeighPercent = a
      .getFloat(R.styleable.DropDownMenu_ddmenuMenuHeightPercent, menuHeighPercent);
  a.recycle();

  //初始化tabMenuView并添加到tabMenuView
  tabMenuView = new LinearLayout(context);
  LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
      ViewGroup.LayoutParams.WRAP_CONTENT);
  tabMenuView.setOrientation(HORIZONTAL);
  tabMenuView.setBackgroundColor(menuBackgroundColor);
  tabMenuView.setLayoutParams(params);
  addView(tabMenuView, 0);

  //为tabMenuView添加下划线
  View underLine = new View(getContext());
  underLine.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpTpPx(1.0f)));
  underLine.setBackgroundColor(underlineColor);
  addView(underLine, 1);

  //初始化containerView并将其添加到DropDownMenu
  containerView = new FrameLayout(context);
  containerView.setLayoutParams(
      new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
          FrameLayout.LayoutParams.MATCH_PARENT));
  addView(containerView, 2);

}
 
Example 16
Source File: CustomSlidingTabIndicator.java    From StickyHeaderViewPager with Apache License 2.0 4 votes vote down vote up
public CustomSlidingTabIndicator(Context ctx, AttributeSet attrs, int defStyle) {
    super(ctx, attrs, defStyle);

    //Request HorizontalScrollView to stretch its content to fill the viewport
    setFillViewport(true);

    //This view will not do any drawing on its own, clear this flag if you override onDraw()
    setWillNotDraw(false);

    //Layout to hold all the tabs
    mTabsContainer = new LinearLayout(ctx);
    mTabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    mTabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));

    //Add the container to HorizontalScrollView as its only child view
    addView(mTabsContainer);

    //Convert the dimensions to DP
    DisplayMetrics dm = getResources().getDisplayMetrics();
    mScrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mScrollOffset, dm);
    mIndicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mIndicatorHeight, dm);
    mUnderlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mUnderlineHeight, dm);
    mDividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mDividerPadding, dm);
    mTabSidePadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mTabSidePadding, dm);
    mTabTopBtmPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mTabTopBtmPadding, dm);
    mDividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, mDividerWidth, dm);
    mTabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mTabTextSize, dm);

    //Get system attrs (android:textSize & android:textColor)
    TypedArray typedArray = ctx.obtainStyledAttributes(attrs, ATTRS);

    mTabTextSize = typedArray.getDimensionPixelSize(0, mTabTextSize);
    mTabTextColor = typedArray.getColor(1, mTabTextColor);

    typedArray.recycle();

    //Get custom attrs
    typedArray = ctx.obtainStyledAttributes(attrs, R.styleable.CustomSlidingTabIndicator);

    mIndicatorColor = typedArray.getColor(R.styleable.CustomSlidingTabIndicator_STIindicatorColor, mIndicatorColor);
    mUnderlineColor = typedArray.getColor(R.styleable.CustomSlidingTabIndicator_STIunderlineColor, mUnderlineColor);
    mDividerColor = typedArray.getColor(R.styleable.CustomSlidingTabIndicator_STIdividerColor, mDividerColor);
    mTabTextColor = typedArray.getColor(R.styleable.CustomSlidingTabIndicator_STItextColor, mTabTextColor);
    mIndicatorHeight = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STIindicatorHeight, mIndicatorHeight);
    mUnderlineHeight = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STIunderlineHeight, mUnderlineHeight);
    mDividerPadding = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STIdividersPadding, mDividerPadding);
    mTabSidePadding = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STItabLeftRightPadding, mTabSidePadding);
    mScrollOffset = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STIscrollOffSet, mScrollOffset);
    mTabTextSize = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STItabTextSize, mTabTextSize);
    mTabBackgroundResId = typedArray.getResourceId(R.styleable.CustomSlidingTabIndicator_STItabBackground, mTabBackgroundResId);
    mShouldExpand = typedArray.getBoolean(R.styleable.CustomSlidingTabIndicator_STIshouldExpand, mShouldExpand);
    mTextAllCap = typedArray.getBoolean(R.styleable.CustomSlidingTabIndicator_STItextCaps, mTextAllCap);
    mTabTopBtmPadding = typedArray.getDimensionPixelSize(R.styleable.CustomSlidingTabIndicator_STItabTopBtmPadding, mTabTopBtmPadding);

    typedArray.recycle();

    //Paint to draw the rectangle box
    mRectPaint = new Paint();
    mRectPaint.setAntiAlias(true);
    mRectPaint.setStyle(Paint.Style.FILL);

    //Paint to draw the divider
    mDividerPaint = new Paint();
    mDividerPaint.setAntiAlias(true);
    mDividerPaint.setStrokeWidth(mDividerWidth);

    //Default: width = wrap_content, height = match_parent
    mDefaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);

    //Expanded: width = 0, height = match_parent, weight = 1.0f
    mExpandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);
}
 
Example 17
Source File: ViewPagerHeader.java    From ZoomHeaderViewPager with Apache License 2.0 4 votes vote down vote up
private LinearLayout createRootContainer() {
    LinearLayout container = new LinearLayout(getContext());
    container.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    container.setOrientation(LinearLayout.HORIZONTAL);
    return container;
}
 
Example 18
Source File: ItemBaseListAdapter.java    From ListView-Swipe-to-Delete with Apache License 2.0 4 votes vote down vote up
private void setMenuLayoutHeight(LinearLayout menuLayout, int newHeight) {
	LinearLayout.LayoutParams la = (LinearLayout.LayoutParams)(menuLayout.getLayoutParams());
	la.height = newHeight;
	menuLayout.setLayoutParams(la);
}
 
Example 19
Source File: AdapterRule.java    From LibreTasks with Apache License 2.0 4 votes vote down vote up
/**
 * Generates a single item in the listview tree widget.
 */
public View getView(int position, View convertView, ViewGroup parent) {

  NodeWrapper it = getNodeWrapper(position);

  LinearLayout ll = new LinearLayout(context);
  ll.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  ll.setMinimumHeight(50);
  ll.setOrientation(LinearLayout.HORIZONTAL);
  ll.setGravity(Gravity.CENTER_VERTICAL);

  ImageView iv = new ImageView(context);
  iv.setImageResource(it.getNode().getItem().getIconResId());
  iv.setAdjustViewBounds(true);
  iv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.WRAP_CONTENT));
  if (listView.getCheckedItemPosition() == position) {
    iv.setBackgroundResource(R.drawable.icon_hilight);
  }

  TextView tv = new TextView(context);
  tv.setText(it.getNode().getItem().getDescriptionShort());
  tv.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,
      LayoutParams.FILL_PARENT));
  tv.setGravity(Gravity.CENTER_VERTICAL);
  tv.setPadding(10, 0, 0, 0);
  tv.setTextSize(14.0f);
  tv.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  tv.setTextColor(context.getResources().getColor(R.color.list_element_text));
  tv.setMinHeight(46);

  // This is where we figure out which tree branch graphics to stack
  // to the left of a node to give the appearance of a real tree widget.
  ArrayList<Integer> branches = it.getBranches();
  for (int i = 0; i < branches.size(); i++) {
    int imageResourceId;
    if (i == branches.size() - 1) {
      // You are whatever I say you are.
      imageResourceId = branches.get(i).intValue();
    } else {
      // Here we do replacements.
      if (branches.get(i).intValue() == R.drawable.treebranch_child_end) {
        // empty png
        imageResourceId = R.drawable.treebranch_parent_empty;
      } else {
        // straight pipe png
        imageResourceId = R.drawable.treebranch_parent;
      }
    }

    ImageView ivBranch = new ImageView(context);
    ivBranch.setImageResource(imageResourceId);
    ivBranch.setAdjustViewBounds(true);
    ivBranch.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.WRAP_CONTENT,
        LayoutParams.WRAP_CONTENT));
    ll.addView(ivBranch);
  }

  ll.addView(iv);
  ll.addView(tv);
  return ll;
}
 
Example 20
Source File: EasyListView4.java    From Cornowser with MIT License 3 votes vote down vote up
private LinearLayout createNewLinearLayout() {
    LinearLayout layout = new LinearLayout(getContext());

    layout.setOrientation(LinearLayout.VERTICAL);

    LayoutParams p = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);

    layout.setLayoutParams(p);

    return layout;
}