Java Code Examples for android.widget.ImageView.setFocusable()

The following are Jave code examples for showing how to use setFocusable() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: PlusGram   File: PagerSlidingTabStrip.java   Source Code and License Vote up 7 votes
private void addIconTab(final int position, int resId) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }
    };
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 2
Project: appinventor-extensions   File: Image.java   Source Code and License Vote up 7 votes
/**
 * Creates a new Image component.
 *
 * @param container  container, component will be placed in
 */
public Image(ComponentContainer container) {
  super(container);

  view = new ImageView(container.$context()) {
    @Override
    public boolean verifyDrawable(Drawable dr) {
      super.verifyDrawable(dr);
      // TODO(user): multi-image animation
      return true;
    }
  };
  view.setFocusable(true);

  // Adds the component to its designated container
  container.$add(this);
}
 
Example 3
Project: KeylineMaterialDesign   File: KeylineDrawService.java   Source Code and License Vote up 7 votes
public void draw() {

        windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        Display deviceDisplay = windowManager.getDefaultDisplay();
        Point point = new Point();
        deviceDisplay.getSize(point);
        deviceWidth = point.x;
        deviceHeight = point.y;

        imageView = new ImageView(this);
        imageView.setClickable(false);
        imageView.setFocusable(false);
        imageView.setMinimumHeight(deviceHeight);
        imageView.setMinimumWidth(deviceWidth);

        drawKeylines();

    }
 
Example 4
Project: airgram   File: PagerSlidingTabStrip.java   Source Code and License Vote up 6 votes
private void addIconTab(final int position, int resId) {
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pager.setCurrentItem(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 5
Project: airgram   File: ScrollSlidingTabStrip.java   Source Code and License Vote up 6 votes
public void addIconTab(int resId) {
    final int position = tabCount++;
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 6
Project: AppCommonFrame   File: BottomNavButton.java   Source Code and License Vote up 6 votes
/**
 * 添加图标
 */
private void addIcon(){
    iconImageView = new ImageView(getContext());
    iconImageView.setFocusable(false);
    iconImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    iconImageView.setImageResource(iconResId);

    int size = DimensUtils.dpToPx(getContext(),20);
    LinearLayout.LayoutParams llp = new LayoutParams(size,size);
    addView(iconImageView,llp);

}
 
Example 7
Project: PlusGram   File: ScrollSlidingTabStrip.java   Source Code and License Vote up 6 votes
public void addIconTab(int resId) {
    final int position = tabCount++;
    ImageView tab = new ImageView(getContext());
    tab.setFocusable(true);
    tab.setImageResource(resId);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            delegate.onPageSelected(position);
        }
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
}
 
Example 8
Project: MenuSet   File: MainContentFragment.java   Source Code and License Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    mImageView = (ImageView) rootView.findViewById(R.id.image_content);
    mImageView.setClickable(true);
    mImageView.setFocusable(true);
    mImageView.setImageResource(res);
    return rootView;
}
 
Example 9
Project: MenuSet   File: Utils.java   Source Code and License Vote up 6 votes
public static ImageView getItemImageButton(Context context, MenuObject item) {
    ImageView imageView = new ImageButton(context);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(lp);
    imageView.setPadding((int) context.getResources().getDimension(R.dimen.menu_item_padding),
            (int) context.getResources().getDimension(R.dimen.menu_item_padding),
            (int) context.getResources().getDimension(R.dimen.menu_item_padding),
            (int) context.getResources().getDimension(R.dimen.menu_item_padding));
    imageView.setClickable(false);
    imageView.setFocusable(false);
    imageView.setBackgroundColor(Color.TRANSPARENT);

    if (item.getColor() != 0) {
        Drawable color = new ColorDrawable(item.getColor());
        imageView.setImageDrawable(color);
    } else if (item.getResource() != 0) {
        imageView.setImageResource(item.getResource());
    } else if (item.getBitmap() != null) {
        imageView.setImageBitmap(item.getBitmap());
    } else if (item.getDrawable() != null) {
        imageView.setImageDrawable(item.getDrawable());
    }
    imageView.setScaleType(item.getScaleType());

    return imageView;
}
 
Example 10
Project: chromium-for-android-56-debug-video   File: InfoBarLayout.java   Source Code and License Vote up 5 votes
/**
 * Constructs a layout for the specified infobar. After calling this, be sure to set the
 * message, the buttons, and/or the custom content using setMessage(), setButtons(), and
 * setCustomContent().
 *
 * @param context The context used to render.
 * @param infoBarView InfoBarView that listens to events.
 * @param iconResourceId ID of the icon to use for the infobar.
 * @param iconBitmap Bitmap for the icon to use, if the resource ID wasn't passed through.
 * @param message The message to show in the infobar.
 */
public InfoBarLayout(Context context, InfoBarView infoBarView, int iconResourceId,
        Bitmap iconBitmap, CharSequence message) {
    super(context);
    mControlLayouts = new ArrayList<InfoBarControlLayout>();

    mInfoBarView = infoBarView;

    // Cache resource values.
    Resources res = getResources();
    mSmallIconSize = res.getDimensionPixelSize(R.dimen.infobar_small_icon_size);
    mSmallIconMargin = res.getDimensionPixelSize(R.dimen.infobar_small_icon_margin);
    mBigIconSize = res.getDimensionPixelSize(R.dimen.infobar_big_icon_size);
    mBigIconMargin = res.getDimensionPixelSize(R.dimen.infobar_big_icon_margin);
    mMarginAboveButtonGroup =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_button_row);
    mMarginAboveControlGroups =
            res.getDimensionPixelSize(R.dimen.infobar_margin_above_control_groups);
    mPadding = res.getDimensionPixelOffset(R.dimen.infobar_padding);
    mMinWidth = res.getDimensionPixelSize(R.dimen.infobar_min_width);
    mAccentColor = ApiCompatibilityUtils.getColor(res, R.color.infobar_accent_blue);

    // Set up the close button. Apply padding so it has a big touch target.
    mCloseButton = new ImageButton(context);
    mCloseButton.setId(R.id.infobar_close_button);
    mCloseButton.setImageResource(R.drawable.btn_close);
    TypedArray a = getContext().obtainStyledAttributes(
            new int [] {R.attr.selectableItemBackground});
    Drawable closeButtonBackground = a.getDrawable(0);
    a.recycle();
    mCloseButton.setBackground(closeButtonBackground);
    mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
    mCloseButton.setOnClickListener(this);
    mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
    mCloseButton.setLayoutParams(new LayoutParams(0, -mPadding, -mPadding, -mPadding));

    // Set up the icon.
    if (iconResourceId != 0 || iconBitmap != null) {
        mIconView = new ImageView(context);
        if (iconResourceId != 0) {
            mIconView.setImageResource(iconResourceId);
        } else if (iconBitmap != null) {
            mIconView.setImageBitmap(iconBitmap);
        }
        mIconView.setLayoutParams(new LayoutParams(0, 0, mSmallIconMargin, 0));
        mIconView.getLayoutParams().width = mSmallIconSize;
        mIconView.getLayoutParams().height = mSmallIconSize;
        mIconView.setFocusable(false);
    }

    // Set up the message view.
    mMessageMainText = message;
    mMessageLayout = new InfoBarControlLayout(context);
    mMessageTextView = mMessageLayout.addMainMessage(prepareMainMessageString());
}