android.widget.TextView#setFocusableInTouchMode ( )源码实例Demo

下面列出了android.widget.TextView#setFocusableInTouchMode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tv-samples   文件: GridItemPresenter.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(),
            R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码2 项目: androidtv-Leanback   文件: GridItemPresenter.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());

    Resources res = parent.getResources();
    int width = res.getDimensionPixelSize(R.dimen.grid_item_width);
    int height = res.getDimensionPixelSize(R.dimen.grid_item_height);

    view.setLayoutParams(new ViewGroup.LayoutParams(width, height));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(parent.getContext(),
            R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码3 项目: alltv   文件: MainFragment.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {

    TextView view = new TextView(parent.getContext());

    view.setLayoutParams(new ViewGroup.LayoutParams(getResources().getInteger(R.integer.GRID_ITEM_WIDTH), getResources().getInteger(R.integer.GRID_ITEM_HEIGHT)));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);

    return new ViewHolder(view);
}
 
源代码4 项目: jellyfin-androidtv   文件: TextItemPresenter.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(ITEM_WIDTH, ITEM_HEIGHT));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    view.setTextSize(32);
    return new ViewHolder(view);
}
 
源代码5 项目: SSForms   文件: FormAdapter.java
private void setAttachPicker(TextView tv, final int position, final LinearLayout layoutRow) {
    tv.setFocusableInTouchMode(false);
    layoutRow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            clickedPosition = position;
            getAttachPickerObservable(attachs).forEach(actionAttach);
        }
    });
}
 
源代码6 项目: leanback-extensions   文件: MainFragment.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
	TextView view = new TextView(parent.getContext());
	view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
	view.setFocusable(true);
	view.setFocusableInTouchMode(true);
	view.setBackgroundColor(getResources().getColor(R.color.default_background));
	view.setTextColor(Color.WHITE);
	view.setGravity(Gravity.CENTER);
	return new ViewHolder(view);
}
 
源代码7 项目: Android-WYSIWYG-Editor   文件: InputExtensions.java
private void addEditableStyling(TextView editText) {
    editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL));
    editText.setFocusableInTouchMode(true);
    editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE);
    editText.setTextColor(Color.parseColor(this.DEFAULT_TEXT_COLOR));
    editText.setPadding(0,30,0,30);
}
 
源代码8 项目: VCL-Android   文件: StringPresenter.java
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView textView = new TextView(parent.getContext());
    textView.setFocusable(true);
    textView.setFocusableInTouchMode(true);
    textView.setBackground(
            parent.getContext().getResources().getDrawable(R.drawable.background_cone));
    return new ViewHolder(textView);
}
 
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(GRID_ITEM_WIDTH, GRID_ITEM_HEIGHT));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
@Override
protected View onCreateDialogView() {
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6,6,6,6);

    TextView promptTextView = new TextView(getContext());
    promptTextView.setText(R.string.preferences_axis_mapping_dialog_text);
    promptTextView.setGravity(Gravity.CENTER_HORIZONTAL);

    mValueTextView = new TextView(getContext());
    mValueTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
    mValueTextView.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueTextView.setPadding(0, 12, 0, 12);


    mValueTextView.setOnGenericMotionListener(this);
    //TODO: is there an easier way to make this work?
    //motion events are not captured when view is not focusable
    mValueTextView.setFocusableInTouchMode(true);
    //if focus is not set, right analog stick events are only recognized after the left analog stick is moved!?!
    mValueTextView.requestFocus();

    layout.addView(promptTextView, params);
    layout.addView(mValueTextView, params);

    return layout;
}
 
源代码11 项目: Telegram-FOSS   文件: FloatingToolbar.java
private View createMenuItemButton(Context context, MenuItem menuItem, int iconTextSpacing) {
    LinearLayout menuItemButton = new LinearLayout(context);
    menuItemButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    menuItemButton.setOrientation(LinearLayout.HORIZONTAL);
    menuItemButton.setMinimumWidth(AndroidUtilities.dp(48));
    menuItemButton.setMinimumHeight(AndroidUtilities.dp(48));
    menuItemButton.setPaddingRelative(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);

    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setFocusable(false);
    textView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    textView.setFocusableInTouchMode(false);
    if (currentStyle == STYLE_DIALOG) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    } else if (currentStyle == STYLE_BLACK) {
        textView.setTextColor(0xfffafafa);
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(0x40ffffff, false));
    } else if (currentStyle == STYLE_THEME) {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    }
    textView.setPaddingRelative(AndroidUtilities.dp(11), 0, 0, 0);
    menuItemButton.addView(textView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, AndroidUtilities.dp(48)));
    if (menuItem != null) {
        updateMenuItemButton(menuItemButton, menuItem, iconTextSpacing);
    }
    return menuItemButton;
}
 
源代码12 项目: Amphitheatre   文件: GridItemPresenter.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(240, 240));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(mContext.getResources().getColor(R.color.primary));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(
            parent.getResources().getInteger( R.integer.preference_square_size ),
            parent.getResources().getInteger( R.integer.preference_square_size ) ) );
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor( parent.getContext().getResources().getColor(R.color.default_background) );
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码14 项目: Android-Commons   文件: UI.java
/**
 * Sets the given `TextView` to be read-only or read-and-write
 *
 * @param view a `TextView` or one of its subclasses
 * @param readOnly whether the view should be read-only or not
 */
public static void setReadOnly(final TextView view, final boolean readOnly) {
	view.setFocusable(!readOnly);
	view.setFocusableInTouchMode(!readOnly);
	view.setClickable(!readOnly);
	view.setLongClickable(!readOnly);
	view.setCursorVisible(!readOnly);
}
 
源代码15 项目: BuildingForAndroidTV   文件: TVDemoFragment.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(200, 200));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码16 项目: BuildingForAndroidTV   文件: TVDemoFragment.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(200, 200));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码17 项目: BuildingForAndroidTV   文件: TVDemoFragment.java
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    TextView view = new TextView(parent.getContext());
    view.setLayoutParams(new ViewGroup.LayoutParams(200, 200));
    view.setFocusable(true);
    view.setFocusableInTouchMode(true);
    view.setBackgroundColor(getResources().getColor(R.color.default_background));
    view.setTextColor(Color.WHITE);
    view.setGravity(Gravity.CENTER);
    return new ViewHolder(view);
}
 
源代码18 项目: Telegram   文件: FloatingToolbar.java
private View createMenuItemButton(Context context, MenuItem menuItem, int iconTextSpacing) {
    LinearLayout menuItemButton = new LinearLayout(context);
    menuItemButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    menuItemButton.setOrientation(LinearLayout.HORIZONTAL);
    menuItemButton.setMinimumWidth(AndroidUtilities.dp(48));
    menuItemButton.setMinimumHeight(AndroidUtilities.dp(48));
    menuItemButton.setPaddingRelative(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);

    TextView textView = new TextView(context);
    textView.setGravity(Gravity.CENTER);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
    textView.setFocusable(false);
    textView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
    textView.setFocusableInTouchMode(false);
    if (currentStyle == STYLE_DIALOG) {
        textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    } else if (currentStyle == STYLE_BLACK) {
        textView.setTextColor(0xfffafafa);
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(0x40ffffff, false));
    } else if (currentStyle == STYLE_THEME) {
        textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        menuItemButton.setBackgroundDrawable(Theme.getSelectorDrawable(false));
    }
    textView.setPaddingRelative(AndroidUtilities.dp(11), 0, 0, 0);
    menuItemButton.addView(textView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, AndroidUtilities.dp(48)));
    if (menuItem != null) {
        updateMenuItemButton(menuItemButton, menuItem, iconTextSpacing);
    }
    return menuItemButton;
}
 
源代码19 项目: pandroid   文件: SnackbarManager.java
private ToastNotifier makeCustomNotification(Activity activity, ToastType toastType, String label, String btnLabel, int drawableRes, int style, int duration, boolean undefinedLoad, final ToastListener listener) {
    if (duration < 0)
        duration = Snackbar.LENGTH_INDEFINITE;
    final Snackbar notif = Snackbar.make(activity.findViewById(android.R.id.content), label, duration);
    if (style == 0) {
        style = R.style.Toast;
    }
    TypedArray attributes = activity.obtainStyledAttributes(style, R.styleable.ToastAppearance);
    int textColor = attributes.getColor(R.styleable.ToastAppearance_toastTextColor, ContextCompat.getColor(activity, R.color.white));
    int buttonTextColor = attributes.getColor(R.styleable.ToastAppearance_toastButtonTextColor, ContextCompat.getColor(activity, R.color.pandroid_green_dark));
    int backgroundColor = attributes.getColor(R.styleable.ToastAppearance_toastBackground, ContextCompat.getColor(activity, R.color.pandroid_green));
    notif.getView().setBackgroundColor(backgroundColor);
    ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_text)).setTextColor(textColor);
    TextView actionView = ((TextView) notif.getView().findViewById(android.support.design.R.id.snackbar_action));
    actionView.setTextColor(buttonTextColor);
    attributes.recycle();

    notif.setCallback(new Snackbar.Callback() {
        @Override
        public void onDismissed(Snackbar snackbar, int event) {
            super.onDismissed(snackbar, event);
            if (listener != null)
                listener.onDismiss();
        }
    });

    Drawable drawable = null;
    if (drawableRes > 0) {
        drawable = ContextCompat.getDrawable(activity, drawableRes);
    }
    actionView.setCompoundDrawablesRelativeWithIntrinsicBounds(null, null, drawable, null);
    if (toastType == ToastType.ACTION && btnLabel != null) {
        notif.setAction(btnLabel, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null)
                    listener.onActionClicked();
            }
        });
    } else if (drawableRes > 0) {
        actionView.setVisibility(View.VISIBLE);
        actionView.setClickable(false);
        actionView.setFocusableInTouchMode(false);
        actionView.setFocusable(false);
        actionView.setEnabled(false);
    }

    if (toastType == ToastType.LOADER) {
        ProgressWheel progressWheel = new ProgressWheel(activity);
        progressWheel.setId(R.id.snakebar_loader);
        if (undefinedLoad)
            progressWheel.spin();

        progressWheel.setBarWidth((int) DeviceUtils.dpToPx(activity, 4));
        progressWheel.setCircleRadius((int) DeviceUtils.dpToPx(activity, 30));
        progressWheel.setBarColor(buttonTextColor);
        progressWheel.setLinearProgress(true);
        ((Snackbar.SnackbarLayout) notif.getView()).addView(progressWheel, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
    }
    notif.show();
    lastShowNotif = notif;
    return new ToastNotifier() {
        @Override
        public void setProgress(int progress) {
            ProgressWheel loader = (ProgressWheel) notif.getView().findViewById(R.id.snakebar_loader);
            if (loader != null) {
                loader.setProgress(progress / 100f);
            }
        }

        @Override
        public void dismiss() {
            notif.dismiss();
        }

    };
}
 
源代码20 项目: ProjectX   文件: SubLayout.java
SubLayout(Context context) {
    super(context);
    setWillNotDraw(false);
    final Resources resources = context.getResources();
    int size = resources.getDimensionPixelOffset(R.dimen.floatingActionModeItemSize);
    int textColor = resources.getColor(R.color.floatingActionModeSubTitleTextColor);
    float textSize = resources.getDimension(R.dimen.floatingActionModeSubTitleTextSize);
    @SuppressLint("CustomViewStyleable") final TypedArray custom =
            context.obtainStyledAttributes(R.styleable.FloatingActionMode);
    size = custom.getDimensionPixelOffset(
            R.styleable.FloatingActionMode_floatingActionModeItemSize, size);
    final int textAppearance = custom.getResourceId(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextAppearance, 0);
    textColor = custom.getColor(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextColor, textColor);
    textSize = custom.getDimension(
            R.styleable.FloatingActionMode_floatingActionModeSubTitleTextSize, textSize);
    custom.recycle();
    setOrientation(VERTICAL);
    mTitle = new TextView(context);
    if (textAppearance != 0)
        mTitle.setTextAppearance(context, textAppearance);
    else {
        final TypedArray a = context.obtainStyledAttributes(
                new int[]{android.R.attr.textAppearanceListItemSmall});
        mTitle.setTextAppearance(context, a.getResourceId(0, 0));
        a.recycle();
    }
    mTitle.setBackgroundDrawable(null);
    mTitle.setEllipsize(TextUtils.TruncateAt.END);
    mTitle.setFocusable(false);
    mTitle.setFocusableInTouchMode(false);
    mTitle.setTypeface(Typeface.create("sans-serif-medium", Typeface.NORMAL));
    mTitle.setGravity(Gravity.CENTER);
    mTitle.setSingleLine();
    mTitle.setTextColor(textColor);
    mTitle.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
    mTitle.setMinimumHeight(size);
    mTitle.setPadding(size, 0, size, 0);
    if (Build.VERSION.SDK_INT >= 16)
        mTitle.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    mTitle.setLayoutParams(new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mList = new SubListView(context);
    mListMaxHeight = mList.getMaxHeight();
    mParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    mParams.weight = 1;
    mCornerCrop.setFillType(Path.FillType.EVEN_ODD);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
    mCropPath.setFillType(Path.FillType.EVEN_ODD);
    mList.setOnItemClickListener(this);
}
 
 方法所在类
 同类方法