當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。