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

The following examples show how to use android.widget.RelativeLayout#findViewById() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QrCodeFinderView.java    From QrCodeScanner with GNU General Public License v3.0 6 votes vote down vote up
private void init(Context context) {
    if (isInEditMode()) {
        return;
    }
    // 需要调用下面的方法才会执行onDraw方法
    setWillNotDraw(false);
    LayoutInflater inflater = LayoutInflater.from(context);
    RelativeLayout relativeLayout = (RelativeLayout) inflater.inflate(R.layout.layout_qr_code_scanner, this);
    FrameLayout frameLayout = (FrameLayout) relativeLayout.findViewById(R.id.qr_code_fl_scanner);
    mFrameRect = new Rect();
    RelativeLayout.LayoutParams layoutParams = (LayoutParams) frameLayout.getLayoutParams();
    mFrameRect.left = (ScreenUtils.getScreenWidth() - layoutParams.width) / 2;
    mFrameRect.top = layoutParams.topMargin;
    mFrameRect.right = mFrameRect.left + layoutParams.width;
    mFrameRect.bottom = mFrameRect.top + layoutParams.height;
}
 
Example 2
Source File: ContactFragment.java    From LoveTalkClient with Apache License 2.0 6 votes vote down vote up
private void initListView() {
	friendsList = (ListView) getView().findViewById(R.id.list_friends);
	LayoutInflater mInflater = LayoutInflater.from(context);
	RelativeLayout headView = (RelativeLayout) mInflater.inflate(
			R.layout.contact_include_new_friend, null);
	msgTipsView = (ImageView) headView.findViewById(R.id.iv_msg_tips);
	newFriendLayout = (LinearLayout) headView.findViewById(R.id.layout_new);


	newFriendLayout.setOnClickListener(this);

	friendsList.addHeaderView(headView);
	userAdapter = new UserFriendAdapter(getActivity(), friends);
	friendsList.setAdapter(userAdapter);
	friendsList.setOnItemClickListener(this);
	friendsList.setOnItemLongClickListener(this);
	friendsList.setOnTouchListener(new OnTouchListener() {

		@Override
		public boolean onTouch(View v, MotionEvent event) {
			Utils.hideSoftInputView(getActivity());
			return false;
		}
	});
}
 
Example 3
Source File: CommentsFragment.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    mLayout = (RelativeLayout) inflater.inflate(
            R.layout.comments_fragment, container, false);

    ImageButton submitButton = (ImageButton)
            mLayout.findViewById(R.id.submitButton);
    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CommentsFragment.this.submitButtonClicked();
        }
    });

    mProgressBar = (ProgressBar) mLayout.findViewById(R.id.progressIndicator);
    mListView = (ListView) mLayout.findViewById(R.id.list);

    /* Set title text to uppercase and roboto font */
    TextView titleText = (TextView) mLayout.findViewById(R.id.titleText);
    mTextUtils.setFont(titleText, TextUtils.FONT_ROBOTOREGULAR);
    String title = mActivity.getString(R.string.menu_view_comments);
    titleText.setText(title);

    return mLayout;
}
 
Example 4
Source File: EditorView.java    From Hillffair17 with GNU General Public License v3.0 5 votes vote down vote up
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 5
Source File: HyperTextView.java    From YCCustomText with Apache License 2.0 5 votes vote down vote up
/**
 * 在特定位置添加ImageView,折行
 * @param index                             索引值
 * @param imagePath                         图片地址
 * @param isWordWrap                        是否折行
 */
public synchronized void addImageViewAtIndex(final int index, String imagePath , boolean isWordWrap) {
    if (index==-1){
        return;
    }
    if(imagePath==null || imagePath.length()==0){
        return;
    }
    Bitmap bmp = BitmapFactory.decodeFile(imagePath);
    final RelativeLayout imageLayout = createImageLayout();
    HyperImageView imageView = 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 6
Source File: CalendarViewInteractor.java    From CustomizableCalendar with MIT License 5 votes vote down vote up
@Override
public void onHeaderBindView(ViewGroup view) {
    RelativeLayout layout = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.calendar_header, view);
    firstDaySelectedTxt = (TextView) layout.findViewById(R.id.first_day_selected);
    lastDaySelectedTxt = (TextView) layout.findViewById(R.id.last_day_selected);
    updateCalendar(calendar);
}
 
Example 7
Source File: PLALoadMoreListView.java    From Lay-s with MIT License 5 votes vote down vote up
private void init(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    setSelector(R.drawable.transparent);

    // footer
    mFooterView = (RelativeLayout) mInflater.inflate(R.layout.common_load_more_footer, this, false);
    mLabLoadMore = (TextView) mFooterView.findViewById(R.id.common_load_more_footer_msg);
    mProgressBarLoadMore = (CircularProgressBar) mFooterView.findViewById(R.id.common_load_more_footer_progress);

    addFooterView(mFooterView);

    super.setOnScrollListener(this);
}
 
Example 8
Source File: EditorView.java    From Nimbus with GNU General Public License v3.0 5 votes vote down vote up
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 9
Source File: CountryCodeAdapter.java    From CountryCodePickerProject with Apache License 2.0 5 votes vote down vote up
public CountryCodeViewHolder(View itemView) {
    super(itemView);
    relativeLayout_main = (RelativeLayout) itemView;
    textView_name = (TextView) relativeLayout_main.findViewById(R.id.textView_countryName);
    textView_code = (TextView) relativeLayout_main.findViewById(R.id.textView_code);
    imageViewFlag = (ImageView) relativeLayout_main.findViewById(R.id.image_flag);
    linearFlagHolder = (LinearLayout) relativeLayout_main.findViewById(R.id.linear_flag_holder);
    divider = relativeLayout_main.findViewById(R.id.preferenceDivider);

    if (codePicker.getDialogTextColor() != 0) {
        textView_name.setTextColor(codePicker.getDialogTextColor());
        textView_code.setTextColor(codePicker.getDialogTextColor());
        divider.setBackgroundColor(codePicker.getDialogTextColor());
    }

    try {
        if (codePicker.getDialogTypeFace() != null) {
            if (codePicker.getDialogTypeFaceStyle() != CountryCodePicker.DEFAULT_UNSET) {
                textView_code.setTypeface(codePicker.getDialogTypeFace(), codePicker.getDialogTypeFaceStyle());
                textView_name.setTypeface(codePicker.getDialogTypeFace(), codePicker.getDialogTypeFaceStyle());
            } else {
                textView_code.setTypeface(codePicker.getDialogTypeFace());
                textView_name.setTypeface(codePicker.getDialogTypeFace());
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 10
Source File: PLALoadMoreListView.java    From SimplifyReader with Apache License 2.0 5 votes vote down vote up
private void init(Context context) {
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    setSelector(R.drawable.transparent);

    // footer
    mFooterView = (RelativeLayout) mInflater.inflate(R.layout.common_load_more_footer, this, false);
    mLabLoadMore = (TextView) mFooterView.findViewById(R.id.common_load_more_footer_msg);
    mProgressBarLoadMore = (CircularProgressBar) mFooterView.findViewById(R.id.common_load_more_footer_progress);

    addFooterView(mFooterView);

    super.setOnScrollListener(this);
}
 
Example 11
Source File: AudioPlayer.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public static ViewHolder get(RelativeLayout audioPlayer) {
    ViewHolder viewHolder = (ViewHolder) audioPlayer.getTag(R.id.TAG_AUDIO_PLAYER_VIEW_HOLDER);
    if (viewHolder == null) {
        viewHolder = new ViewHolder();
        viewHolder.runtime = audioPlayer.findViewById(R.id.runtime);
        viewHolder.progress = audioPlayer.findViewById(R.id.progress);
        viewHolder.playPause = audioPlayer.findViewById(R.id.play_pause);
        audioPlayer.setTag(R.id.TAG_AUDIO_PLAYER_VIEW_HOLDER, viewHolder);
    }
    return viewHolder;
}
 
Example 12
Source File: FriendActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
private void initListView() {
	list_friends = (ListView) findViewById(R.id.list_friends);
	RelativeLayout headView = (RelativeLayout) View.inflate(context, R.layout.layout_new_friend, null);
	iv_msg_tips = (ImageView) headView.findViewById(R.id.iv_msg_tips);
	headView.findViewById(R.id.layout_new).setOnClickListener(this);
	headView.findViewById(R.id.layout_near).setOnClickListener(this);
	headView.findViewById(R.id.layout_add).setOnClickListener(this);
	list_friends.addHeaderView(headView);
	userAdapter = new UserFriendAdapter(context, friends);
	list_friends.setAdapter(userAdapter);
	list_friends.setOnItemClickListener(this);
	list_friends.setOnItemLongClickListener(this);
}
 
Example 13
Source File: PluginSimplePlayer.java    From Dota2Helper with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化加载页面
 */
private void initLoadInfoPage() {
	if (null == mActivity)
		return;
	LayoutInflater mLayoutInflater = LayoutInflater.from(mActivity);
	if (null == mLayoutInflater)
		return;
	loadingInfoLayout = (RelativeLayout) mLayoutInflater.inflate(
			R.layout.yp_detail_loading_info_page, null);
	if (null == loadingInfoLayout)
		return;
	infoSeekBar = (SeekBar) loadingInfoLayout
			.findViewById(R.id.loading_info_seekbar);

}
 
Example 14
Source File: AppsFragment.java    From MemoryCleaner with Apache License 2.0 5 votes vote down vote up
@Override public RelativeLayout setDialogValues(String[] memory) {
    RelativeLayout dialog_process_detail
            = (RelativeLayout) getActivity().getLayoutInflater()
                                            .inflate(
                                                    R.layout.dialog_process_detail,
                                                    null);
    if (memory == null || memory.length == 0) return dialog_process_detail;
    TextView mTextView2 = (TextView) dialog_process_detail.findViewById(
            R.id.memory);
    TextView mTextView3 = (TextView) dialog_process_detail.findViewById(
            R.id.unit);
    mTextView2.setText(memory[0]);
    mTextView3.setText(memory[1]);
    return dialog_process_detail;
}
 
Example 15
Source File: CallActivity.java    From Linphone4Android with GNU General Public License v3.0 5 votes vote down vote up
private void displayConferenceHeader(){
	conferenceList.setVisibility(View.VISIBLE);
	RelativeLayout headerConference = (RelativeLayout) inflater.inflate(R.layout.conference_header, container, false);
	conferenceStatus = (ImageView) headerConference.findViewById(R.id.conference_pause);
	conferenceStatus.setOnClickListener(this);
	conferenceList.addView(headerConference);

}
 
Example 16
Source File: AccessibilityGuideFloatView.java    From FileManager with Apache License 2.0 5 votes vote down vote up
private void initWindowView() {
    mContentView = (RelativeLayout) LayoutInflater.from(mContext).inflate(R.layout.accessibility_guide_float_window_layout, null);
    mContentView.setFocusableInTouchMode(true);
    mFloatViewLayout = (AccessibilityGuideFloatViewLayout) mContentView.findViewById(R.id.guide_float_window_layout);
    mFloatViewLayout.getCloseView().setOnClickListener(this);
    mContentView.setOnKeyListener((v, keyCode, event) -> {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            dimiss();
        }
        return false;
    });
}
 
Example 17
Source File: CallOnGoingContactsAdapter.java    From toktok-android with GNU General Public License v3.0 4 votes vote down vote up
CallOnGoingContactsViewHolder(@NonNull RelativeLayout itemView) {
    super(itemView);
    mFriendImage = itemView.findViewById(R.id.call_ongoing_contact_img);
    mFriendName = itemView.findViewById(R.id.call_ongoing_contact_name);
    mFriendCallTime = itemView.findViewById(R.id.call_ongoing_contact_call_time);
}
 
Example 18
Source File: PullToUpdateListView.java    From PullToUpdate-ListView with Apache License 2.0 4 votes vote down vote up
private void init(Context context) {
	// initial states
	pullState = DOING_NOTHING;
	mode = MODE.UP_AND_DOWN;
	isFooterLoading = false;
	/*
	 * Header
	 */
	mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

	mHeaderView = (RelativeLayout) mInflater.inflate(R.layout.header, this, false);
	headerMessage = (TextView) mHeaderView.findViewById(R.id.headerMessage);
	headerImage = (ImageView) mHeaderView.findViewById(R.id.headerImage);
	headerProgressBar = (ProgressBar) mHeaderView.findViewById(R.id.headerProgressbar);
	headerImage.setVisibility(View.VISIBLE);
	headerProgressBar.setVisibility(View.INVISIBLE);

	headerHeigh = mHeaderView.getPaddingTop();// getLayoutParams().height;
	headerFixedOriginalHeight = 100;// mHeaderView.getHeight();
	releaseTrigger = 2;

	/*
	 * Footer
	 */
	mFooterView = (RelativeLayout) mInflater.inflate(R.layout.footer, this, false);
	footerMessage = (TextView) mFooterView.findViewById(R.id.footer_message);
	footerProgressBar = (ProgressBar) mFooterView.findViewById(R.id.footer_progressbar);

	addFooterView(mFooterView);
	footerHeigh = mFooterView.getPaddingBottom();
	footerMessage.setVisibility(View.GONE);

	/*
	 * Animation
	 */
	// Down
	mImageFlipDownAnimation = new RotateAnimation(0, -180, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mImageFlipDownAnimation.setInterpolator(new LinearInterpolator());
	mImageFlipDownAnimation.setDuration(250);
	mImageFlipDownAnimation.setFillAfter(true);
	// Up
	mImageFlipUpAnimation = new RotateAnimation(-180, 0, RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mImageFlipUpAnimation.setInterpolator(new LinearInterpolator());
	mImageFlipUpAnimation.setDuration(250);
	mImageFlipUpAnimation.setFillAfter(true);
	/*
	 * 
	 */

	setVerticalFadingEdgeEnabled(false);
	setSmoothScrollbarEnabled(true);

	super.setOnScrollListener(this);

	Log.d("FRED", "init: " + (getHeight() + " - " + mFooterView.getBottom()));

}
 
Example 19
Source File: RejectedCallAdapter.java    From toktok-android with GNU General Public License v3.0 4 votes vote down vote up
RejectedCallViewHolder(@NonNull RelativeLayout itemView) {
    super(itemView);
    mMessage = itemView.findViewById(R.id.reject_item_message);
}
 
Example 20
Source File: CircularBarPager.java    From CircularBarPager with MIT License 4 votes vote down vote up
/**
 * Init the view by getting the {@link CircularBar},
 * the {@link android.support.v4.view.ViewPager} and the {@link com.viewpagerindicator.CirclePageIndicator}.
 * Init also some default values as PageTranformer etc...
 */
private void initializeView(AttributeSet attrs, int defStyleAttr) {
    if (attrs != null) {
        final TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs, R.styleable.CircularViewPager,
                defStyleAttr, 0);

        boolean enableOnClick = attributes.getBoolean(R.styleable.CircularViewPager_progress_pager_on_click_enabled, false);
        isPaddingSet = false;

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.circularbar_view_pager, this);

        mCircularBar = (CircularBar) view.findViewById(R.id.circular_bar);
        mViewPager = (ViewPager) view.findViewById(R.id.view_pager);
        mCirclePageIndicator = (CirclePageIndicator) view.findViewById(R.id.circle_page_indicator);

        //Default init
        if(mCircularBar != null){
            mCircularBar.loadStyledAttributes(attrs, defStyleAttr);
        }
        if(mViewPager != null){
            mViewPager.setPageTransformer(false, new FadeViewPagerTransformer());
        }


        //If we enable onClick, ie. we can switch between pages with both a swipe and a touch
        //Touch just goes to the next page % number of pages
        if (enableOnClick) {
            final GestureDetectorCompat tapGestureDetector = new GestureDetectorCompat(getContext(), new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    mViewPager.setCurrentItem((mViewPager.getCurrentItem() + 1) % mViewPager.getAdapter().getCount());
                    return super.onSingleTapConfirmed(e);
                }
            });
            if(mViewPager != null){
                mViewPager.setOnTouchListener(new OnTouchListener() {
                    public boolean onTouch(View v, MotionEvent event) {
                        tapGestureDetector.onTouchEvent(event);
                        return false;
                    }
                });
            }

        }
    }
}