Java Code Examples for android.widget.TextView#setHeight()

The following examples show how to use android.widget.TextView#setHeight() .
Example 1
Project: Android-Notification   File: ViewSwitcherWrapper.java    License: Apache License 2.0 6 votes vote down vote up
private void adjustTextViewHeight() {
    View view = getView();
    if (view == null) {
        return;
    }

    TextSwitcher textSwitcher = (TextSwitcher) view;
    TextView curr = (TextView) textSwitcher.getCurrentView();
    TextView next = (TextView) textSwitcher.getNextView();
    int currH = curr.getLineCount() * curr.getLineHeight();
    int nextH = next.getLineCount() * next.getLineHeight();
    if (currH != nextH) {
        curr.setHeight(currH);
        next.setHeight(currH);
    }
}
 
Example 2
Project: jellyfin-androidtv   File: CustomPlaybackOverlayFragment.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onPostExecute(Void aVoid) {
    Timber.d("*** Display programs post execute");
    if (mCurrentDisplayChannelEndNdx < mAllChannels.size() - 1) {
        // Show a paging row for channels below
        int pageDnEnd = mCurrentDisplayChannelEndNdx + PAGE_SIZE;
        if (pageDnEnd >= mAllChannels.size()) pageDnEnd = mAllChannels.size() - 1;

        TextView placeHolder = new TextView(mActivity);
        placeHolder.setHeight(LiveTvGuideActivity.PAGEBUTTON_HEIGHT);
        mChannels.addView(placeHolder);

        mProgramRows.addView(new GuidePagingButton(mActivity, mFragment, mCurrentDisplayChannelEndNdx + 1, getString(R.string.lbl_load_channels) + mAllChannels.get(mCurrentDisplayChannelEndNdx + 1).getNumber() + " - " + mAllChannels.get(pageDnEnd).getNumber()));
    }

    mChannelStatus.setText(displayedChannels + " of " + mAllChannels.size() + " channels");
    mFilterStatus.setText(" for next " + mGuideHours + " hours");
    mFilterStatus.setTextColor(Color.GRAY);

    mGuideSpinner.setVisibility(View.GONE);
    if (firstRow != null) firstRow.requestFocus();
}
 
Example 3
Project: ParallaxScroll   File: SingleParallaxListView.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.list_one_parallax);
	ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view);
	CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this));
	
	TextView v = new TextView(this);
	v.setText("PARALLAXED");
	v.setGravity(Gravity.CENTER);
	v.setTextSize(40);
	v.setHeight(200);
	v.setBackgroundResource(R.drawable.item_background);
	
	listView.addParallaxedHeaderView(v);
	listView.setAdapter(adapter);
}
 
Example 4
Project: LiteSyllabusView   File: LiteSyllabusView.java    License: Apache License 2.0 6 votes vote down vote up
private void setupSectionSidebar() {
    layoutSectionSidebar = new LinearLayout(mContext);
    layoutSectionSidebar.setOrientation(VERTICAL);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(mSectionSidebarWidth, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutSectionSidebar.setLayoutParams(params);

    for (int i = 1; i <= mSectionNumber; ++i) {
        layoutSectionSidebar.addView(getHorizontalDividerView());
        TextView tvSectionNumberTitle = new TextView(mContext);
        tvSectionNumberTitle.setWidth(mSectionSidebarWidth);
        tvSectionNumberTitle.setHeight(mSectionHeight);
        tvSectionNumberTitle.setText("" + i);
        tvSectionNumberTitle.setTextSize(SECTION_SIDEBAR_TEXT_SIZE);
        tvSectionNumberTitle.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle));
        tvSectionNumberTitle.setGravity(Gravity.CENTER);
        tvSectionNumberTitle.setTypeface(mTitleTypeface);
        layoutSectionSidebar.addView(tvSectionNumberTitle);
    }

    layoutSectionSidebar.setBackgroundColor(ContextCompat.getColor(mContext, R.color.bgSectionSidbar));
}
 
Example 5
Project: UltimateAndroid   File: SingleParallaxListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.parallax_scroll_list_one_parallax);
	ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view);
	CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this));
	
	TextView v = new TextView(this);
	v.setText("PARALLAXED");
	v.setGravity(Gravity.CENTER);
	v.setTextSize(40);
	v.setHeight(200);
	v.setBackgroundResource(R.drawable.parallax_scroll_item_background);
	
	listView.addParallaxedHeaderView(v);
	listView.setAdapter(adapter);
}
 
Example 6
Project: Shield   File: LoadingBaseCell.java    License: MIT License 6 votes vote down vote up
@Override
public View loadingView() {
    LinearLayout rootView = (LinearLayout) getRootView();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setText("loading: 加载中");
    textView.setGravity(Gravity.CENTER);
    textView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mResetOnClickListener != null) {
                mResetOnClickListener.onClick(v);
            }
        }
    });
    rootView.addView(textView);
    return rootView;
}
 
Example 7
Project: UltimateAndroid   File: SingleParallaxListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.parallax_scroll_list_one_parallax);
	ParallaxListView listView = (ParallaxListView) findViewById(R.id.list_view);
	CustomListAdapter adapter = new CustomListAdapter(LayoutInflater.from(this));
	
	TextView v = new TextView(this);
	v.setText("PARALLAXED");
	v.setGravity(Gravity.CENTER);
	v.setTextSize(40);
	v.setHeight(200);
	v.setBackgroundResource(R.drawable.parallax_scroll_item_background);
	
	listView.addParallaxedHeaderView(v);
	listView.setAdapter(adapter);
}
 
Example 8
Project: Shield   File: DefaultDividerAgent.java    License: MIT License 6 votes vote down vote up
private View createShowView() {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = ViewUtils.dip2px(getContext(), 30);

    ItemViewHolder itemViewHolder = new ItemViewHolder();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    itemViewHolder.textView = textView;

    rootView.addView(textView, params);
    rootView.setTag(itemViewHolder);
    return rootView;
}
 
Example 9
Project: Shield   File: LoadingBaseCell.java    License: MIT License 6 votes vote down vote up
@Override
public View loadingMoreView() {

    LinearLayout rootView = (LinearLayout) getRootView();

    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setText("loadingmore: 正在载入");
    textView.setGravity(Gravity.CENTER);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mResetOnClickListener != null) {
                mResetOnClickListener.onClick(v);
            }
        }
    });
    rootView.addView(textView);
    return rootView;
}
 
Example 10
Project: Shield   File: LoadingBaseCell.java    License: MIT License 6 votes vote down vote up
@Override
public View loadingMoreFailedView() {

    LinearLayout rootView = (LinearLayout) getRootView();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setText("loadingmore fail: 点击重新加载");
    textView.setGravity(Gravity.CENTER);
    textView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mLoadingMoreRetryListener != null) {
                mLoadingMoreRetryListener.onClick(v);
            }
        }
    });
    rootView.addView(textView);
    return rootView;
}
 
Example 11
Project: Shield   File: LoadingStatusAgent.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(ViewGroup parent, int viewType) {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = ViewUtils.dip2px(getContext(), 30);

    itemViewHolder = new ItemViewHolder();
    TextView textView = new TextView(mContext);
    textView.setHeight(ViewUtils.dip2px(getContext(), 50));
    textView.setGravity(Gravity.CENTER_VERTICAL);
    itemViewHolder.textView = textView;

    rootView.addView(textView, params);
    rootView.setTag(itemViewHolder);
    return rootView;
}
 
Example 12
Project: UltimateAndroid   File: SingleParallaxExpandableListView.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.parallax_scroll_expand_list_one_parallax);
	ParallaxExpandableListView listView = (ParallaxExpandableListView) findViewById(R.id.list_view);
	
	TextView v = new TextView(this);
	v.setText("PARALLAXED");
	v.setGravity(Gravity.CENTER);
	v.setTextSize(40);
	v.setHeight(200);
	v.setBackgroundResource(R.drawable.parallax_scroll_item_background);
	
	listView.addParallaxedHeaderView(v);
	CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(LayoutInflater.from(this));
	listView.setAdapter(adapter);
}
 
Example 13
Project: ParallaxScroll   File: SingleParallaxExpandableListView.java    License: MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.expand_list_one_parallax);
	ParallaxExpandableListView listView = (ParallaxExpandableListView) findViewById(R.id.list_view);
	
	TextView v = new TextView(this);
	v.setText("PARALLAXED");
	v.setGravity(Gravity.CENTER);
	v.setTextSize(40);
	v.setHeight(200);
	v.setBackgroundResource(R.drawable.item_background);
	
	listView.addParallaxedHeaderView(v);
	CustomExpandableListAdapter adapter = new CustomExpandableListAdapter(LayoutInflater.from(this));
	listView.setAdapter(adapter);
}
 
Example 14
Project: xposed-rimet   File: PluginSettingsAdapter.java    License: Apache License 2.0 5 votes vote down vote up
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {

        CommentItemView commentItemView = new CommentItemView(getContext());
        TextView textView = commentItemView.getContentView();
        textView.setTextSize(16);
        textView.setMinLines(1);
        textView.setMaxLines(1);
        textView.setHeight(DisplayUtil.dip2px(getContext(), 32));

        return commentItemView;
    }
 
Example 15
Project: VCL-Android   File: StringPresenter.java    License: Apache License 2.0 5 votes vote down vote up
public void onBindViewHolder(ViewHolder viewHolder, Object item) {
    Resources res = viewHolder.view.getContext().getResources();
    TextView tv = (TextView) viewHolder.view;
    tv.setText(item.toString());
    if (res.getString(R.string.preferences).equals(item.toString())) {
        tv.setBackground(res.getDrawable(R.drawable.ic_menu_preferences_big));
    }
    tv.setHeight(res.getDimensionPixelSize(R.dimen.grid_card_thumb_height));
    tv.setWidth(res.getDimensionPixelSize(R.dimen.grid_card_thumb_width));
}
 
Example 16
Project: tickmate   File: TickAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Used to create and insert the week separator
 *
 * @param tickGrid the ViewGroup into which the week separator will be inserted
 */
private void addStartWeekSeparator(ViewGroup tickGrid) {
    TextView splitter2 = new TextView(this.context);
    splitter2.setText("");
    splitter2.setHeight(5);
    tickGrid.addView(splitter2);
    TextView splitter = new TextView(this.context);
    splitter.setText("");
    splitter.setHeight(11);
    splitter.setBackgroundResource(R.drawable.center_line);
    splitter.setPadding(0, 20, 0, 0);
    tickGrid.addView(splitter);
}
 
Example 17
Project: SmallGdufe-Android   File: ScheduleView.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 横的分界线
 *
 * @return
 */
private View getWeekTransverseLine() {
    TextView mWeekline = new TextView(getContext());
    mWeekline.setBackgroundColor(getResources().getColor(R.color.view_line));
    mWeekline.setHeight(TimeTableLineHeight);
    mWeekline.setWidth(LayoutParams.FILL_PARENT);
    return mWeekline;
}
 
Example 18
Project: LiteSyllabusView   File: LiteSyllabusView.java    License: Apache License 2.0 5 votes vote down vote up
private void setupWeekdayHeader() {
    layoutWeekdayHeader = new LinearLayout(mContext);
    layoutWeekdayHeader.setOrientation(HORIZONTAL);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mWeekdayHeaderHeight);
    layoutWeekdayHeader.setLayoutParams(params);

    TextView tvEmptyCellOnTopAndLeft = new TextView(mContext);
    tvEmptyCellOnTopAndLeft.setWidth(mSectionSidebarWidth);
    tvEmptyCellOnTopAndLeft.setHeight(mWeekdayHeaderHeight);
    tvEmptyCellOnTopAndLeft.setText("\\");
    tvEmptyCellOnTopAndLeft.setTextSize(WEEKDAY_TITLE_TEXT_SIZE);
    tvEmptyCellOnTopAndLeft.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle));
    tvEmptyCellOnTopAndLeft.setGravity(Gravity.CENTER);
    tvEmptyCellOnTopAndLeft.setTypeface(mTitleTypeface);
    layoutWeekdayHeader.addView(tvEmptyCellOnTopAndLeft);

    for (int i = 0; i < mWeekdayNumber; ++i) {
        layoutWeekdayHeader.addView(getVerticalDividerView());
        TextView tvWeekdayTitle = new TextView(mContext);
        tvWeekdayTitle.setWidth(mSectionWidth);
        tvWeekdayTitle.setHeight(mWeekdayHeaderHeight);
        tvWeekdayTitle.setText(WEEKDAY_TITLES[i]);
        tvWeekdayTitle.setTextSize(WEEKDAY_TITLE_TEXT_SIZE);
        tvWeekdayTitle.setTextColor(ContextCompat.getColor(mContext, R.color.textTitle));
        tvWeekdayTitle.setGravity(Gravity.CENTER);
        tvWeekdayTitle.setTypeface(mTitleTypeface);
        layoutWeekdayHeader.addView(tvWeekdayTitle);
    }

    layoutWeekdayHeader.setBackgroundColor(ContextCompat.getColor(mContext, R.color.bgWeekdayHeader));
}
 
Example 19
Project: Shield   File: LoadingStatusMoreAgent.java    License: MIT License 5 votes vote down vote up
@Override
public View onCreateView(ViewGroup parent, int viewType) {
    LinearLayout rootView = new LinearLayout(mContext);
    rootView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setBackgroundColor(getContext().getResources().getColor(android.R.color.white));

    if (viewType == 0) {
        View containView = LayoutInflater.from(getContext()).inflate(R.layout.agent_status_loading_more, rootView, false);
        setLoadingStatus(containView);
        rootView.addView(containView);
    } else {
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        params.setMargins(ViewUtils.dip2px(getContext(), 30), 0, 0, 0);
        itemViewHolder = new ItemViewHolder();
        TextView textView = new TextView(mContext);
        textView.setHeight(ViewUtils.dip2px(getContext(), 50));
        textView.setGravity(Gravity.CENTER_VERTICAL);
        itemViewHolder.textView = textView;
        rootView.addView(textView, params);
        rootView.setTag(itemViewHolder);
    }

    return rootView;
}
 
Example 20
Project: SmartChart   File: PanelListAdapter.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 初始化横向表头的布局,必须在所有的布局都载入完之后才能调用
 * <p>
 * must be called in pl_root.post();
 */
private void initRowLayout() {

    if (rowDataList == null) {
        Log.e("PanelList", "custom Row data list is strongly recommended! Call setRowDataList(List<String> rowDataList) in your panel adapter");
    }
    int rowCount = ll_contentItem.getChildCount();

    List<String> rowDataList1 = getRowDataList(rowCount);

    //分隔线的设置,如果content的item设置了分割线,那row使用相同的分割线,除非单独给row设置了分割线
    ll_row.setBackgroundColor(Color.parseColor(rowColor));
    if (rowDivider == null) {
        ll_row.setDividerDrawable(ll_contentItem.getDividerDrawable());
    } else {
        ll_row.setDividerDrawable(rowDivider);
    }

    // 获得row一共有多少个item,然后使用循环往里面添加对应个数个TextView(简单粗暴)
    for (int i = 0; i < rowCount; i++) {
        View contentItem = ll_contentItem.getChildAt(i);// 获得item的item,以便获取宽度
        TextView rowItem = new TextView(context);
        rowItem.setText(rowDataList1.get(i));//设置文字
        Paint rowPaint=rowItem.getPaint();
        rowPaint.setFakeBoldText(false);
        rowPaint.setColor(context.getResources().getColor(R.color.color_646464));
        rowPaint.setTextSize(CommonUtils.dp2px(context,15));
        rowItem.setWidth(contentItem.getWidth()-2);//设置宽度
        rowItem.setHeight(titleHeight);//设置高度
        rowItem.setGravity(Gravity.CENTER);
        TextView line=new TextView(context);
        ll_row.addView(rowItem);
        if (i<rowCount-1){
            line.setBackgroundColor(Color.WHITE);
            line.setWidth(2);
            line.setHeight(titleHeight);
            ll_row.addView(line);
        }


    }
}