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


Java TextView.setCompoundDrawablesWithIntrinsicBounds方法代码示例

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


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

示例1: onCreateView

import android.widget.TextView; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment, null);
    mEdit = (EditText) view.findViewById(R.id.edit);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mEdit.setCompoundDrawablesRelativeWithIntrinsicBounds(R.drawable.drawable_left_selector,
                R.drawable.drawable_top_selector,
                R.drawable.drawable_right_selector,
                R.drawable.drawable_bottom_selector);
    }
    mEdit1 = (EditText) view.findViewById(R.id.edit1);
    mEdit1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.drawable_left_selector,
            R.drawable.drawable_top_selector,
            R.drawable.drawable_right_selector,
            R.drawable.drawable_bottom_selector);
    mText1 = (TextView) view.findViewById(R.id.text1);
    mText1.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.drawable.drawable_left_selector),
            getResources().getDrawable(R.drawable.drawable_top_selector),
            getResources().getDrawable(R.drawable.drawable_right_selector),
            getResources().getDrawable(R.drawable.drawable_bottom_selector));
    return view;
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:24,代码来源:LastFragment.java

示例2: getIndicatorView

import android.widget.TextView; //导入方法依赖的package包/类
/** 返回设置好的底部按钮
     * @param indicator1
     * @return
     */
    private View getIndicatorView(Indicator indicator1) {
        View view = LayoutInflater.from(this).inflate(R.layout.tab_indicator, null);
        TextView indicator = (TextView) view.findViewById(R.id.tab_title);

        indicator.setText(getString(indicator1.getResName()));

        indicator.setTextSize(TypedValue.COMPLEX_UNIT_SP,10);
        Drawable icon = this.getResources().getDrawable(indicator1.getResIcon());
//        自定义ICON大小
//        icon.setBounds(0, 0, 75, 75);
//        indicator.setCompoundDrawables(null,icon,null,null);
        indicator.setCompoundDrawablePadding(3);
        indicator.setCompoundDrawablesWithIntrinsicBounds(null, icon, null, null);
        indicator.setPadding(0,8,0,5);


        return view;
    }
 
开发者ID:FallenCrood,项目名称:Review-,代码行数:23,代码来源:MainActivity.java

示例3: setView

import android.widget.TextView; //导入方法依赖的package包/类
private boolean setView(int id, String packageName) {
    TextView donate = (TextView) findViewById(id);
    PackageManager pm = getPackageManager();
    try {
        ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
        if (!info.enabled) {
            return false;
        }
        CharSequence label = getLabel(pm, info);
        donate.setContentDescription(label);
        donate.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(pm.getApplicationIcon(info)), null, null);
        donate.setText(label);
        donate.setClickable(true);
        donate.setOnClickListener(this);
        donate.setVisibility(View.VISIBLE);
        return true;
    } catch (PackageManager.NameNotFoundException e) {
        UILog.d("cannot find package " + packageName, e);
        return false;
    }
}
 
开发者ID:brevent,项目名称:prevent,代码行数:22,代码来源:UserGuideActivity.java

示例4: getView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.gestures_item, parent, false);
    }

    final NamedGesture gesture = getItem(position);
    final TextView label = (TextView) convertView;

    label.setTag(gesture);
    label.setText(gesture.name);
    label.setCompoundDrawablesWithIntrinsicBounds(mThumbnails.get(gesture.gesture.getID()),
            null, null, null);

    return convertView;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:17,代码来源:GestureBuilderActivity.java

示例5: findViews

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 初始化viwe
 */
private void findViews() {
    LayoutInflater inflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.item_expand_shink, this);
    mTvContent = (TextView) findViewById(R.id.expandable_text);
    mTvContent.setOnClickListener(this);
    mTvExpandCollapse = (TextView) findViewById(R.id.expand_collapse);
    if(showExpandCollapseDrawable) {
        mTvExpandCollapse.setCompoundDrawablesWithIntrinsicBounds(null, null, mCollapsed ? mExpandDrawable : mCollapseDrawable, null);
    }
    mTvExpandCollapse.setText(mCollapsed ? getResources().getString(R.string.expand) : getResources().getString(R.string.shink));
    mTvExpandCollapse.setOnClickListener(this);

    mTvContent.setTextColor(contentTextColor);
    mTvContent.getPaint().setTextSize(contentTextSize);

    mTvExpandCollapse.setTextColor(collapseExpandTextColor);
    mTvExpandCollapse.getPaint().setTextSize(collapseExpandTextSize);

    //设置收起展开位置:左或者右
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
    lp.gravity = grarity;
    mTvExpandCollapse.setLayoutParams(lp);
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:28,代码来源:ExpandableTextView.java

示例6: setupTabIcons

import android.widget.TextView; //导入方法依赖的package包/类
private void setupTabIcons() {

        TextView tabOne = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabOne.setText("ONE");
        tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.play, 0, 0);
        tabLayout.getTabAt(0).setCustomView(tabOne);

        TextView tabTwo = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabTwo.setText("TWO");
        tabTwo.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.music_list, 0, 0);
        tabLayout.getTabAt(1).setCustomView(tabTwo);

        TextView tabThree = (TextView) LayoutInflater.from(this).inflate(R.layout.custom_tab, null);
        tabThree.setText("THREE");
        tabThree.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.youtube, 0, 0);
        tabLayout.getTabAt(2).setCustomView(tabThree);
    }
 
开发者ID:yusufkocak1,项目名称:TMP-Music_player,代码行数:18,代码来源:MainActivity.java

示例7: getView

import android.widget.TextView; //导入方法依赖的package包/类
public View getView(int position, View convertView, ViewGroup parent) {
    final int type = getItemViewType(position);
    if (convertView == null) {
        if (type == ITEM_VIEW_TYPE_CATEGORY) {
            convertView = inflater.inflate(R.layout.browser_category_item_shortcut, parent, false);
        } else {
            convertView = inflater.inflate(R.layout.browser_category_item_separator, parent, false);
        }
    }

    final TextView tv = (TextView) convertView;
    if (type == ITEM_VIEW_TYPE_CATEGORY) {
        convertView.setBackgroundResource(R.drawable.category_item_background_normal);
        // Set the category name
        ItemData item = (ItemData) mCategoryList.get(position);
        tv.setText(item.text);
        if(item.icon!=-1)
            tv.setCompoundDrawablesWithIntrinsicBounds(item.icon, 0 , 0 , 0);
        else tv.setCompoundDrawablesWithIntrinsicBounds(0, 0 , 0 , 0);
    }
    else {
        tv.setText((CharSequence) mCategoryList.get(position));
    }

    return convertView;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:27,代码来源:BrowserCategory.java

示例8: convert

import android.widget.TextView; //导入方法依赖的package包/类
@Override
protected void convert(final BaseViewHolder helper, WeatherCity item) {
    TextView tvName = helper.getView(R.id.tv_card_city_name);
    if (helper.getAdapterPosition() == 0) {
        tvName.setCompoundDrawablesWithIntrinsicBounds(null, null,
                ThemeUtil.setTintDrawable(R.drawable.ic_location, mContext,
                        ThemeUtil.getCurrentColorPrimary(mContext)), null);
    }
    tvName.setText(item.getCityName());
    helper.setText(R.id.tv_card_weather, TextUtils.isEmpty(item.getWeatherText()) ? "NA" : item.getWeatherText());
    helper.setText(R.id.tv_card_temp, TextUtils.isEmpty(item.getWeatherTemp()) ? "NA" : item.getWeatherTemp() + "℃");
    final ImageView imageView = helper.getView(R.id.iv_card_weather);
    WeatherUtil.getInstance().getWeatherDict(item.getWeatherCode()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SimpleSubscriber<WeatherBean>() {
        @Override
        public void onNext(WeatherBean weatherBean) {
            Glide.with(mContext).load(weatherBean.getIcon()).diskCacheStrategy(DiskCacheStrategy.ALL).into(imageView);
        }
    });
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:20,代码来源:CardWeatherAdapter.java

示例9: applyIconTint

import android.widget.TextView; //导入方法依赖的package包/类
private void applyIconTint(Bundle args, TextView textView, @DrawableRes int drawableRes) {
    if (args.getInt(ARG_ICON_TINT) != 0) {
        Drawable drawable = getResources().getDrawable(drawableRes);
        Drawable wrappedDrawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(wrappedDrawable, ContextCompat.getColor(getActivity(), args.getInt(ARG_ICON_TINT)));
        textView.setCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null);
    }
}
 
开发者ID:saschpe,项目名称:android-social-fragment,代码行数:9,代码来源:SocialFragment.java

示例10: removeItems

import android.widget.TextView; //导入方法依赖的package包/类
private void removeItems(int tag) {

        for (int i = tabList.size() - 1; i > tag; i--) {
            tabList.remove(i);
            tabParent.removeViewAt(i);
        }
        TextView textView = (TextView) tabParent.getChildAt(tag);
        textView.setTextColor(selectorColor);
        textView.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);
        compileScroll();
        resetListViewSelector();
    }
 
开发者ID:lanyan520,项目名称:Idea-ChainSelector,代码行数:13,代码来源:ChainSelectorView.java

示例11: setMedia

import android.widget.TextView; //导入方法依赖的package包/类
public void setMedia(BaseMedia media) {
    if (media instanceof ImageMedia) {
        mVideoLayout.setVisibility(GONE);
        setCover(((ImageMedia) media).getThumbnailPath());
    } else if (media instanceof VideoMedia) {
        mVideoLayout.setVisibility(VISIBLE);
        VideoMedia videoMedia = (VideoMedia) media;
        TextView durationTxt = ((TextView) mVideoLayout.findViewById(R.id.video_duration_txt));
        durationTxt.setText(videoMedia.getDuration());
        durationTxt.setCompoundDrawablesWithIntrinsicBounds(BoxingManager.getInstance().getBoxingConfig().getVideoDurationRes(), 0, 0, 0);
        ((TextView) mVideoLayout.findViewById(R.id.video_size_txt)).setText(videoMedia.getSizeByUnit());
        setCover(videoMedia.getPath());
    }
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:15,代码来源:MediaItemLayout.java

示例12: setDefaultDrawable

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * 设置 textview 的 drawableLeft  drawableRight  drawablePadding
 *
 * @param textView
 * @param drawableLeft
 * @param drawableRight
 * @param drawablePadding
 */
public void setDefaultDrawable(TextView textView, Drawable drawableLeft, Drawable drawableRight, int drawablePadding) {
    if (drawableLeft != null || drawableRight != null) {
        textView.setVisibility(VISIBLE);
    }

    textView.setCompoundDrawablesWithIntrinsicBounds(drawableLeft, null, drawableRight, null);
    textView.setCompoundDrawablePadding(drawablePadding);
}
 
开发者ID:songjiabin,项目名称:MySelfDemo,代码行数:17,代码来源:SuperTextView_mySelef.java

示例13: updateLayout

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View updateLayout(boolean topLayout, int position, View view, boolean dropdown, boolean selected) {
    // the defuault layout is an TextView
    TextView tv = (TextView) view;
    tv.setCompoundDrawablesWithIntrinsicBounds(R.mipmap.ic_launcher, 0, 0, 0);
    return view;
}
 
开发者ID:MFlisar,项目名称:RecyclerViewPreferences,代码行数:8,代码来源:IconStyleWithIcon.java

示例14: getView

import android.widget.TextView; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = ((Activity) context).getLayoutInflater();
    View row = convertView;
    if(row == null) {
        row = inflater.inflate(resource, parent, false);
    }

    TextView txtTitle = (TextView) row.findViewById(R.id.drawer_item_text);

    if (items != null && items.length > position) {
        txtTitle.setText(items[position]);
        switch (position) {
            case 0:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_drawer_overview, 0, 0, 0);
                break;
            case 1:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_drawer_bookmarks, 0, 0, 0);
                break;
            case 2:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_drawer_notifications, 0, 0, 0);
                break;
            case 3:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_server, 0, 0, 0);
                break;
            case 4:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_drawer_about, 0, 0, 0);
                break;
            case 5:
                txtTitle.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_drawer_logout, 0, 0, 0);
                break;
        }
    }

    return row;
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:37,代码来源:MenuAdapter.java

示例15: setCompoundDrawablesRelativeWithIntrinsicBounds

import android.widget.TextView; //导入方法依赖的package包/类
/**
 * @see android.widget.TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(int, int, int,
 *      int)
 */
public static void setCompoundDrawablesRelativeWithIntrinsicBounds(TextView textView,
        int start, int top, int end, int bottom) {
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1) {
        // Work around the platform bug described in setCompoundDrawablesRelative() above.
        boolean isRtl = isLayoutRtl(textView);
        textView.setCompoundDrawablesWithIntrinsicBounds(isRtl ? end : start, top,
                isRtl ? start : end, bottom);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR1) {
        textView.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
    } else {
        textView.setCompoundDrawablesWithIntrinsicBounds(start, top, end, bottom);
    }
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:18,代码来源:ApiCompatibilityUtils.java


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