Java Code Examples for android.widget.RelativeLayout.findViewById()

The following are Jave code examples for showing how to use findViewById() of the android.widget.RelativeLayout 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: YCCustomText   File: HyperTextView.java   Source Code and License Vote up 6 votes
/**
 * 在特定位置添加ImageView
 */
public void addImageViewAtIndex(final int index, String imagePath) {
    if(imagePath==null || imagePath.length()==0){
        return;
    }
    Bitmap bmp = BitmapFactory.decodeFile(imagePath);
    final RelativeLayout imageLayout = createImageLayout();
    HyperImageView imageView = (HyperImageView) imageLayout.findViewById(R.id.edit_imageView);
    //Picasso.with(getContext()).load(imagePath).centerCrop().into(imageView);
    Glide.with(getContext()).load(imagePath).crossFade().centerCrop().into(imageView);
    //imageView.setImageBitmap(bmp);    //
    //imageView.setBitmap(bmp);         //这句去掉,保留下面的图片地址即可,优化图片占用
    imageView.setAbsolutePath(imagePath);
    // 调整imageView的高度
    int imageHeight = 500;
    if (bmp != null) {
        imageHeight = allLayout.getWidth() * bmp.getHeight() / bmp.getWidth();
        // 使用之后,还是回收掉吧
        bmp.recycle();
    }
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, imageHeight);
    lp.bottomMargin = 10;
    imageView.setLayoutParams(lp);
    allLayout.addView(imageLayout, index);
}
 
Example 2
Project: Coin-Tracker   File: BaseActivity.java   Source Code and License Vote up 6 votes
@Override
public void setContentView(@LayoutRes int layoutResID) {
    super.setContentView(layoutResID);
    baseLayout = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.activity_base, null);
    setContentView(baseLayout);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    tvToolbarTitle = (TextView) findViewById(R.id.tvToolbarTitle);
    tvActionButton = (TextView) findViewById(R.id.tvActionButton);
    tvActionDescription = (TextView) findViewById(R.id.tvActionDescription);
    tvAbout = (TextView) findViewById(R.id.tvAbout);
    rlUserAction = (RelativeLayout) findViewById(R.id.rlUserAction);
    rlContainer = (RelativeLayout) findViewById(R.id.rlContainer);
    ivToolbarImage = (ImageView) findViewById(R.id.ivToolbarImage);
    setSupportActionBar(toolbar);
    ViewStub stub = (ViewStub) baseLayout.findViewById(R.id.container);
    stub.setLayoutResource(layoutResID);
    stub.inflate();
    ButterKnife.bind(this);
}
 
Example 3
Project: tumbviewer   File: PhotoPostVH.java   Source Code and License Vote up 6 votes
private void setTrailContent() {
    List<TrailItem> trails = postsItem.getTrail();
    if (trails != null && trails.size() > 0) {
        trailLayout.removeAllViews();
        createTrailView(trails.size());
        for (int i = 0; i < trails.size(); i++) {
            RelativeLayout layout = trailViewCache.get(i);
            SimpleDraweeView avatar = (SimpleDraweeView) layout.findViewById(R.id.trail_avatar);
            TextView name = (TextView) layout.findViewById(R.id.trail_name);
            TextView content = (TextView) layout.findViewById(R.id.trail_content);
            FrescoUtils.setTumblrAvatarUri(avatar, trails.get(i).getBlog().getName(), 128);
            name.setText(trails.get(i).getBlog().getName());
            content.setText(fromHtlmCompat(trails.get(i).getContent_raw()));
            layout.setTag(trails.get(i).getBlog().getName());
            trailLayout.addView(layout);
        }
        trailLayout.setVisibility(View.VISIBLE);
    } else {
        trailLayout.setVisibility(View.GONE);
    }
}
 
Example 4
Project: leoapp-sources   File: ScanFragment.java   Source Code and License Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.fragment_scan, container, false);

    final EssensbonActivity activityReference = (EssensbonActivity) getActivity();
    final Button scan = rootView.findViewById(R.id.scan_button);

    final Handler handler = new Handler();
    final Runnable r = new Runnable() {
        @Override
        public void run() {
            scan.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    activityReference.scan();
                }
            });
        }
    };
    handler.postDelayed(r, 100);

    if (EssensbonUtils.mensaModeEnabled())
        handler.removeCallbacks(r);

    return rootView;
}
 
Example 5
Project: Divertio   File: SongFixedAdapter.java   Source Code and License Vote up 6 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    final RelativeLayout songListLayout = (RelativeLayout) songListInflater.inflate(R.layout.list_item_song_fixed, parentView, false);
    if (position % 2 - 1 == 0) {
        songListLayout.setBackgroundResource(R.color.gray_2);
    } else {
        songListLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get the parts of a song layout
    //ImageView songItemIcon = (ImageView) songListLayout.findViewById(R.id.song_icon);
    TextView songItemName = (TextView) songListLayout.findViewById(R.id.song_name);
    TextView songItemArtist = (TextView) songListLayout.findViewById(R.id.song_composer);

    // Set the parts equal to the corresponding song
    SongData songItem = songDataList.get(position);
    //songItemIcon.setImageDrawable(songItem.getSongCover());
    songItemName.setText(songItem.getSongName());
    songItemArtist.setText(songItem.getSongArtist());

    // Set position as tag
    songListLayout.setTag(position);
    return songListLayout;
}
 
Example 6
Project: YCCustomText   File: HyperTextEditor.java   Source Code and License Vote up 6 votes
/**
 * 生成图片View
 */
private RelativeLayout createImageLayout() {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_image_view, null);
    layout.setTag(viewTagIndex++);
    View closeView = layout.findViewById(R.id.image_close);
    //closeView.setVisibility(GONE);
    closeView.setTag(layout.getTag());
    closeView.setOnClickListener(btnListener);
    return layout;
}
 
Example 7
Project: BlogBookApp   File: SpaceNavigationView.java   Source Code and License Vote up 5 votes
/**
 * Change item text if space navigation already set up
 *
 * @param itemIndex Target position
 * @param newText   Text to change
 */
public void changeItemTextAtPosition(int itemIndex, String newText) {
    if (itemIndex < 0 || itemIndex > spaceItems.size()) {
        throwArrayIndexOutOfBoundsException(itemIndex);
    } else {
        SpaceItem spaceItem = spaceItems.get(itemIndex);
        RelativeLayout textAndIconContainer = (RelativeLayout) spaceItemList.get(itemIndex);
        TextView spaceItemIcon = (TextView) textAndIconContainer.findViewById(R.id.space_text);
        spaceItemIcon.setText(newText);
        spaceItem.setItemName(newText);
        changedItemAndIconHashMap.put(itemIndex, spaceItem);
    }
}
 
Example 8
Project: justintrain-client-android   File: ItemBuilder.java   Source Code and License Vote up 5 votes
public ItemBuilder addItemGroupHeader(String header) {
    view = inflater.inflate(R.layout.item_element_header, parent, false);
    RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.rl_container);
    TextView       tv = (TextView) rl.findViewById(R.id.tv_header);
    tv.setText(header);
    return this;
}
 
Example 9
Project: BlogBookApp   File: BadgeHelper.java   Source Code and License Vote up 5 votes
/**
 * Force show badge without animation
 *
 * @param view      target budge
 * @param badgeItem BadgeItem object
 */
static void forceShowBadge(RelativeLayout view, BadgeItem badgeItem, boolean shouldShowBadgeWithNinePlus) {
    Utils.changeViewVisibilityVisible(view);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        view.setBackground(makeShapeDrawable(badgeItem.getBadgeColor()));
    } else {
        view.setBackgroundDrawable(makeShapeDrawable(badgeItem.getBadgeColor()));
    }
    TextView badgeTextView = (TextView) view.findViewById(R.id.badge_text_view);
    if (shouldShowBadgeWithNinePlus)
        badgeTextView.setText(badgeItem.getBadgeText());
    else
        badgeTextView.setText(badgeItem.getFullBadgeText());
}
 
Example 10
Project: android-project-gallery   File: EmptyView.java   Source Code and License Vote up 5 votes
private void setUp(Context context)
{
	mRootView = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.wrapper_empty_view, this);
	mEmptyView = (RelativeLayout) mRootView.findViewById(R.id.empty_container);
	mGifView = (ImageView) mRootView.findViewById(R.id.empty_gif);
	mGifShadowView = (ImageView) mRootView.findViewById(R.id.empty_gif_panel);
	mIndicatorView = (ImageView) mRootView.findViewById(R.id.empty_indicator);
	mMessageView = (TextView) mRootView.findViewById(R.id.message);
	
	// addView(mRootView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	
	mEmptyView.setVisibility(View.GONE);
}
 
Example 11
Project: YCCustomText   File: HyperTextView.java   Source Code and License Vote up 5 votes
/**
 * 生成图片View
 */
private RelativeLayout createImageLayout() {
    RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.edit_image_view, null);
    layout.setTag(viewTagIndex++);
    View closeView = layout.findViewById(R.id.image_close);
    closeView.setVisibility(GONE);
    return layout;
}
 
Example 12
Project: Bigbang   File: ArcTipViewController.java   Source Code and License Vote up 5 votes
private void initView() {
    showBigBang = SPHelper.getBoolean(ConstantUtil.TOTAL_SWITCH, true);
    isStick=SPHelper.getBoolean(ConstantUtil.FLOATVIEW_IS_STICK,false);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        Point point = new Point();
        mWindowManager.getDefaultDisplay().getSize(point);
        mScreenWidth = point.x;
        mScreenHeight = point.y;
    } else {
        mScreenWidth = mWindowManager.getDefaultDisplay().getWidth();
        mScreenHeight = mWindowManager.getDefaultDisplay().getHeight();
    }
    if (showBigBang) {
        mCurrentIconAlpha =  SPHelper.getInt(ConstantUtil.FLOATVIEW_ALPHA, 70) / 100f;
    } else {
        mCurrentIconAlpha = 0.6f * SPHelper.getInt(ConstantUtil.FLOATVIEW_ALPHA, 70) / 100f;
    }

    iconFloatView = (LinearLayout) View.inflate(mContext, R.layout.arc_float_icon, null);
    floatImageView = ((ImageView) iconFloatView.findViewById(R.id.float_image));
    acrFloatView = (RelativeLayout) View.inflate(mContext, R.layout.arc_view_float, null);
    archMenu = (ArcMenu) acrFloatView.findViewById(R.id.arc_menu);
    initIcon();
    archMenu.setOnModeSeletedListener(new ArcMenu.OnModeSeletedListener() {
        @Override
        public void onModeSelected() {
            showFloatImageView();
        }

        @Override
        public void onNothing() {

        }
    });
    // event listeners
    acrFloatView.setOnTouchListener(this);
    iconFloatView.setOnTouchListener(this);
}
 
Example 13
Project: android-project-gallery   File: EmptyViewProgressBar.java   Source Code and License Vote up 5 votes
private void setUp(Context context)
{
	mRootView = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.wrapper_empty_view, this);
	mEmptyView = (RelativeLayout) mRootView.findViewById(R.id.container);
	mProgressBar = (ProgressBar) mRootView.findViewById(R.id.progressBar);
	mBackground = (ImageView) mRootView.findViewById(R.id.background);
	mMessage = (TextView) mRootView.findViewById(R.id.message);

	mEmptyView.setVisibility(View.GONE);
}
 
Example 14
Project: Nimbus   File: EditorView.java   Source Code and License Vote up 5 votes
private void createImageViewAtIndex(Bitmap bmp, int index,String imageUrl) {
    RelativeLayout view= (RelativeLayout) inflater.inflate(R.layout.item_image,null);
    EditorImageView imageView= (EditorImageView) view.findViewById(R.id.editorImageView);
    imageView.setImageBitmap(bmp);
    imageView.setAbsoluteUrl(imageUrl);

    int imageHeight = getWidth() * bmp.getHeight() / bmp.getWidth();
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, imageHeight);
    imageView.setLayoutParams(lp);
    view.setOnClickListener(onClickListener);
    allLayout.addView(view, index);
}
 
Example 15
Project: FastAndroid   File: Recognizer.java   Source Code and License Vote up 5 votes
private void initViews() {
    setClickable(true);
    setBackgroundColor(getResources().getColor(R.color.rc_recognizerview_bg_normal));
    RelativeLayout recognizerContainer = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.rc_view_recognizer, null);
    View rlMic = recognizerContainer.findViewById(R.id.rl_mic);
    rlMic.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mIat == null || !mIat.isListening()) {
                startRecognize();
            } else {
                reset();
            }
        }
    });
    imgMic = (ImageView) recognizerContainer.findViewById(R.id.img_mic);

    TextView tvClear = (TextView) recognizerContainer.findViewById(R.id.btn_clear);
    tvClear.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != resultCallBack) {
                resultCallBack.onClearClick();
            }
        }
    });
    rlBottom = (RelativeLayout) recognizerContainer.findViewById(R.id.rl_bottom);
    addView(recognizerContainer);
    random = new Random();
}
 
Example 16
Project: FiveMinsMore   File: GpxManager.java   Source Code and License Vote up 5 votes
GpxManager(Activity context) {
    this.mContext = context;

    managerView = (RelativeLayout) mContext.getLayoutInflater().inflate(R.layout.manager_gpx, null);

    treeView = new AndroidTreeView(mContext, root);
    treeView.setDefaultAnimation(true);
    treeView.setDefaultContainerStyle(R.style.TreeNodeStyleCustom);
    treeView.setUse2dScroll(true);
    treeView.setSelectionModeEnabled(true);

    LinearLayout contentView = (LinearLayout) managerView.findViewById(R.id.gpx_content);
    contentView.addView(treeView.getView());
}
 
Example 17
Project: Divertio   File: SongAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    final RelativeLayout songListLayout = (RelativeLayout) songListInflater.inflate(R.layout.list_item_song, parentView, false);
    if (position % 2 - 1 == 0) {
        songListLayout.setBackgroundResource(R.color.gray_2);
    } else {
        songListLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get the parts of a song layout
    //ImageView songItemIcon = (ImageView) songListLayout.findViewById(R.id.song_icon);
    ImageView songOverflowIcon = (ImageView) songListLayout.findViewById(R.id.song_overflow);
    TextView songItemName = (TextView) songListLayout.findViewById(R.id.song_name);
    TextView songItemArtist = (TextView) songListLayout.findViewById(R.id.song_composer);

    // Set the parts equal to the corresponding song
    SongData songItem = songDataList.get(position);
    //songItemIcon.setImageDrawable(songItem.getSongCover());
    songItemName.setText(songItem.getSongName());
    songItemArtist.setText(songItem.getSongArtist());

    // Set on click listener for overflow
    songOverflowIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((MainActivity) activity).showChoiceMenu(songListLayout, position);
        }
    });

    // Set position as tag
    songListLayout.setTag(position);
    return songListLayout;
}
 
Example 18
Project: Divertio   File: AlbumAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_album, parentView, false);
    if (position % 2 - 1 == 0) {
        relativeLayout.setBackgroundResource(R.color.gray_2);
    } else {
        relativeLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get parts of layout
    ImageView albumCover = (ImageView) relativeLayout.findViewById(R.id.album_cover);
    TextView albumName = (TextView) relativeLayout.findViewById(R.id.album_name);
    TextView albumSize = (TextView) relativeLayout.findViewById(R.id.album_size);

    // Get values
    String name = keyList.get(position);
    Drawable cover = songAlbumList.get(name).get(0).getSongCover();
    RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(activity.getResources(), ((BitmapDrawable) cover).getBitmap());
    drawable.setCornerRadius(50.0f);
    int size = songAlbumList.get(name).size();

    // Set values
    albumCover.setImageDrawable(drawable);
    albumName.setText(name);
    if (size == 1) {
        albumSize.setText("1 song");
    } else {
        albumSize.setText(Integer.toString(size) + " songs");
    }

    // Return
    relativeLayout.setTag(position);
    return relativeLayout;
}
 
Example 19
Project: Divertio   File: ArtistAdapter.java   Source Code and License Vote up 5 votes
@Override
public View getView(final int position, final View convertView, ViewGroup parentView) {
    relativeLayout = (RelativeLayout) layoutInflater.inflate(R.layout.list_item_artist, parentView, false);
    if (position % 2 - 1 == 0) {
        relativeLayout.setBackgroundResource(R.color.gray_2);
    } else {
        relativeLayout.setBackgroundResource(R.color.gray_3);
    }

    // Get parts of layout
    TextView artistName = (TextView) relativeLayout.findViewById(R.id.artist_name);
    TextView artistSize = (TextView) relativeLayout.findViewById(R.id.artist_size);

    // Get values
    String name = keyList.get(position);
    int size = songArtistList.get(name).size();

    // Set values
    artistName.setText(name);
    if (size == 1) {
        artistSize.setText("1 song");
    } else {
        artistSize.setText(Integer.toString(size) + " songs");
    }

    // Return
    relativeLayout.setTag(position);
    return relativeLayout;
}
 
Example 20
Project: atlant-android   File: BaseActivity.java   Source Code and License Vote up 4 votes
@Override
public void setContentView(@LayoutRes int layoutResID) {
  RelativeLayout rootLayout = (RelativeLayout) getLayoutInflater().inflate(R.layout.activity_base, null);

  FrameLayout activityContainer = rootLayout.findViewById(R.id.base_activity_content);
  getLayoutInflater().inflate(layoutResID, activityContainer, true);
  super.setContentView(rootLayout);
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  drawerHelper = new DrawerHelper(this);

  setupComponent(MyApplication.get(this).getAppComponent());
  ButterKnife.bind(this);

  toolbar.setTitle("");
  FontsUtils.toOctarineBold(getContext(), toolbarTitle);
  setSupportActionBar(toolbar);
  if (useToolbar()) {
    toolbar.setVisibility(View.VISIBLE);
  } else {
    toolbar.setVisibility(View.GONE);
  }

  if (useSwipeRefresh()) {
    swipeRefreshLayout.setEnabled(true);
    swipeRefreshLayout.setColorSchemeColors(ContextCompat.getColor(getContext(), R.color.accent));
    swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
      @Override
      public void onRefresh() {
        if (useSwipeRefresh()) {
          onRefreshSwipe();
        }
      }
    });
  } else {
    swipeRefreshLayout.setEnabled(false);
  }

  if (useCustomToolbar()) {
    baseCustomViewToolbar.addView(getCustomToolbar());
    baseCustomViewToolbar.setVisibility(View.VISIBLE);
  } else {
    baseCustomViewToolbar.setVisibility(View.GONE);
  }
  setDrawerMenu();
  initUI();
}