android.widget.RelativeLayout Java Examples

The following examples show how to use android.widget.RelativeLayout. 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: FavActivity.java    From AndroidReview with GNU General Public License v3.0 6 votes vote down vote up
private void creatView() {
    //小圆点
    mFAB = (FloatingActionButton) findViewById(R.id.fab);

    //布局
    mMainLayout = (ScrollView) findViewById(R.id.sv_main_test);
    mAnswerSelectLayout = (LinearLayout) findViewById(R.id.ly_select_answers);
    mRyAnswer = (RelativeLayout) findViewById(R.id.rl_answer);

    //TextView
    mTvQuestion = (TextView) findViewById(R.id.tv_test_question);
    mTvAnswer = (TextView) findViewById(R.id.tv_answer);
    mTvAnswerLong = (TextView) findViewById(R.id.tv_answer_long);

    //button
    mBtShowAnswer = (TextView) findViewById(R.id.bt_show_answer);

}
 
Example #2
Source File: DefaultLoadView.java    From QRefreshLayout with MIT License 6 votes vote down vote up
public DefaultLoadView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
    setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    tvContent = new TextView(context);
    tvContent.setId(View.generateViewId());
    addView(tvContent);
    RelativeLayout.LayoutParams contentParams = (LayoutParams) tvContent.getLayoutParams();
    contentParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    progressBar = new ProgressBar(context);
    addView(progressBar);
    final float density = getContext().getResources().getDisplayMetrics().density;
    RelativeLayout.LayoutParams params = (LayoutParams) progressBar.getLayoutParams();
    params.width = (int) (20 * density);
    params.height = (int) (20 * density);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    params.rightMargin = (int) (10 * density);
    params.addRule(RelativeLayout.LEFT_OF, tvContent.getId());
    progressBar.setLayoutParams(params);
}
 
Example #3
Source File: AddViewsByJavaActivity.java    From Skeleton with Apache License 2.0 6 votes vote down vote up
void startAndEndViewsSkeleton() {

        // Bind view
        RelativeLayout mainLayout2 = findViewById(R.id.mainLayout2);
        AppCompatImageButton btn3 = findViewById(R.id.btn3);
        AppCompatImageButton btn4 = findViewById(R.id.btn4);

        SkeletonViewGroup skeletonViewGroup = new SkeletonViewGroup(getApplicationContext());
        ArrayList<SkeletonModel> skeletonModels = new ArrayList<>();

        // Add Btn 1 and Btn 2
        skeletonModels.add(new SkeletonModelBuilder()
                .setStartView(btn3) // AddView start
                .setEndView(btn4)// AddView end
                .build());


        skeletonViewGroup.setSkeletonModels(skeletonModels);

        // Add SkeletonGroup
        ViewGroup.LayoutParams layout = new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        mainLayout2.addView(skeletonViewGroup, layout);
    }
 
Example #4
Source File: GarbageCleanActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
private void initView() {
    this.mBack = (ImageView) findViewById(R.id.phone_garbage_clean_back);
    this.mScanButton = (Button) findViewById(R.id.phone_garbage_clean_scan);
    this.mBackgroundView = (ImageView) findViewById(R.id.bg_phone_garbage_clean_image);
    this.mBackgroundView.setBackgroundResource(2130837643);
    this.mHousekeeperView = (ImageView) findViewById(R.id.iv_phone_garbage_housekeeper);
    this.mHousekeeperView.setBackgroundResource(2130838207);
    this.mGarbageFileTotalSizeTextView = (TextView) findViewById(R.id.garbage_file_total_size);
    this.mGarbageFileUnitTextView = (TextView) findViewById(R.id.garbage_file_size_unit);
    this.mGarbageFileText = (TextView) findViewById(R.id.garbage_file_text);
    this.mLayout = (RelativeLayout) findViewById(R.id.rl_garbage_file_info);
    this.mLayout.setVisibility(4);
    this.mListAdapter = new GarbageFileListAdapter(this, this.mGarbageFileList);
    this.mListAdapter.setSelectionList(this.mGarbageFileTypeSelectionList);
    this.mListView = (ListView) findViewById(R.id.garbage_file_list);
    this.mListView.setAdapter(this.mListAdapter);
    this.mListView.setChoiceMode(1);
    this.mListView.setVisibility(4);
}
 
Example #5
Source File: Settings.java    From Hangar with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void updateListView(final boolean setAdapter) {
    Runnable runnable = new Runnable() {
        public void run() {
            if (!mAppsLoaded) {
                RelativeLayout bg = (RelativeLayout) lv.getParent();
                bg.findViewById(R.id.loading_text).setVisibility(View.GONE);

                mAppsLoaded = true;
            }
            if (setAdapter) {
                lv.setAdapter(mAppRowAdapter);
            }
            lv.invalidateViews();
            mAppRowAdapter.notifyDataSetChanged();
        }
    };
    mInstance.runOnUiThread(runnable);
}
 
Example #6
Source File: GDMopub.java    From GodotAds with Apache License 2.0 6 votes vote down vote up
private void createBanner() {
       RelativeLayout layout = new RelativeLayout(activity);
       layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
       ((Godot)activity).layout.addView(layout);

	FrameLayout.LayoutParams AdParams = new FrameLayout.LayoutParams(
					 FrameLayout.LayoutParams.MATCH_PARENT,
					 FrameLayout.LayoutParams.WRAP_CONTENT);

	if(moPubView != null) { layout.removeView(moPubView); }

	if (_config.optString("BannerGravity", "BOTTOM").equals("BOTTOM")) {
		AdParams.gravity = Gravity.BOTTOM;
	} else { AdParams.gravity = Gravity.TOP; }

	final String banner_unit_id =
	_config.optString("BannerAdId", activity.getString(R.string.gads_mopub_banner_test_id));

	moPubView = new MoPubView(activity);
	moPubView.setLayoutParams(AdParams);
	moPubView.setAdUnitId(banner_unit_id); // Enter your Ad Unit ID from www.mopub.com
	moPubView.setBannerAdListener(banner_listener);
	moPubView.setAutorefreshEnabled(true);
	moPubView.setVisibility(View.INVISIBLE);
	moPubView.loadAd();

	layout.addView(moPubView);
}
 
Example #7
Source File: FortyEight.java    From Simple-Solitaire with GNU General Public License v3.0 6 votes vote down vote up
public void setStacks(RelativeLayout layoutGame, boolean isLandscape, Context context) {

        setUpCardWidth(layoutGame, isLandscape, 8 + 1, 8 + 4);

        int spacing = setUpHorizontalSpacing(layoutGame, 8, 9);
        int startPos = (int) (layoutGame.getWidth() / 2 - 4 * Card.width - 3.5 * spacing);

        stacks[17].view.setX((int) (layoutGame.getWidth() / 2 + 3 * Card.width + 3.5 * spacing));
        stacks[17].view.setY((isLandscape ? Card.width / 4 : Card.width / 2) + 1);
        stacks[17].setImageBitmap(Stack.backgroundTalon);

        stacks[16].setX(stacks[17].getX() - spacing - Card.width);
        stacks[16].setY(stacks[17].getY());

        for (int i = 0; i < 8; i++) {
            stacks[8 + i].setX(startPos + i * (spacing + Card.width));
            stacks[8 + i].setY(stacks[17].getY() + Card.height + (isLandscape ? Card.width / 4 : Card.width / 2));
            stacks[8 + i].setImageBitmap(Stack.background1);
        }

        for (int i = 0; i < 8; i++) {
            stacks[i].setX(startPos + i * (spacing + Card.width));
            stacks[i].setY(stacks[8].getY() + Card.height + (isLandscape ? Card.width / 4 : Card.width / 2));
        }

    }
 
Example #8
Source File: ChatMessageView.java    From ChatMessageView with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void initContent() {
    arrowImage = new ImageView(getContext());
    arrowImage.setId(ViewUtil.generateViewId());

    containerLayout = new RelativeLayout(getContext());
    containerLayout.setId(ViewUtil.generateViewId());

    setShowArrow(showArrow);
    setContentPadding((int) contentPadding);

    super.addView(arrowImage, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    super.addView(containerLayout, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    updatePositionAndGravity();

    updateColors();
    this.setClickable(true);
}
 
Example #9
Source File: NaviSetLineActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
@Override
public void switchShowRouteLineDetail() {
    if (showState == ShowState.showing || showState == ShowState.unshowing)
        return;
    height = mAnslMapBox.getHeight();

    if (showState == ShowState.unshow) {
        if (showState == ShowState.showed)
            return;
        mAnslOutBottomBox.setVisibility(View.GONE);
        mAnslVoiceBt.setVisibility(View.GONE);
        findViewById(R.id.ansl_route_detail_list_box).setVisibility(View.VISIBLE);
        startHeight = mAnslRouteLineBox.getHeight();
        mAnslRouteLineBox.getLayoutParams().height = startHeight;
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mAnslRouteDetailBottomBox.getLayoutParams();
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        layoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
    }

    mAnimateToTargetPosition.reset();
    mAnimateToTargetPosition.setInterpolator(new AccelerateInterpolator());
    mAnimateToTargetPosition.setDuration(300);
    mAnimateToTargetPosition.setAnimationListener(animationListener);
    mAnslRouteDetailBottomBox.startAnimation(mAnimateToTargetPosition);
}
 
Example #10
Source File: SearchListViewNoText.java    From SearchListView with MIT License 6 votes vote down vote up
/**
 * 获取头部视图
 *
 * @return View
 */
private View getHeaderView() {
    if (viewHeader == null) {
        viewHeader = LayoutInflater.from(getContext()).inflate(R.layout.model_pull_listview_head_no_text, null);

        headContentLayout = (RelativeLayout) viewHeader.findViewById(R.id.head_contentLayout);
        progressBarHeader = (ProgressBar) viewHeader.findViewById(R.id.pulldown_footer_loading);

        layoutContent = (RelativeLayout) viewHeader.findViewById(R.id.layoutContent);

        final ViewConfiguration configuration = ViewConfiguration.get(getContext());
        mTouchSlop = configuration.getScaledTouchSlop();
    }

    if (!isEnableRefresh) {
        headContentLayout.setVisibility(View.GONE);
    }

    return viewHeader;
}
 
Example #11
Source File: NavitationLayout.java    From NavigationBar with Apache License 2.0 6 votes vote down vote up
/**
 * 设置导航条颜色
 * @param context
 * @param height
 * @param color
 * @param currentPosition
 */
public void setNavLine(Activity context, int height, int color, int currentPosition)
{
    if(textViews != null)
    {
        navWidth = getScreenWidth(context) / textViews.length;
    }
    height = dip2px(context,height);
    System.out.println("width:" + navWidth);

    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, height);
    navLine = new View(context);
    navLine.setLayoutParams(layoutParams);
    navLine.setBackgroundColor(context.getResources().getColor(color));

    LayoutParams lp = new LayoutParams(navWidth, height);
    lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
    addView(navLine, lp);
    moveBar(navLine, navWidth, widOffset, currentPosition);
}
 
Example #12
Source File: ProfileFragment.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void setupDeviderView(View view, int parentLayout, int childVerticalLineLayout) {
    final RelativeLayout layout = (RelativeLayout) view.findViewById(parentLayout);
    final RelativeLayout childLayout = (RelativeLayout) view.findViewById(childVerticalLineLayout);
    ViewTreeObserver viewTreeObserver = layout.getViewTreeObserver();


    viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            layout.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            int height = layout.getMeasuredHeight();
            float marginPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, LEFT_MARGIN, getActivity().getResources().getDisplayMetrics());
            float liineWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, LINE_WIDTH, getActivity().getResources().getDisplayMetrics());
            RelativeLayout.LayoutParams layoutPrams = new RelativeLayout.LayoutParams((int) liineWidth, height);
            layoutPrams.setMargins((int) marginPx, 0, 0, 0);
            childLayout.setLayoutParams(layoutPrams);
        }
    });
}
 
Example #13
Source File: NotificationDisplay.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Initialization of the Activity after it is first created.  Must at least
 * call {@link android.app.Activity#setContentView setContentView()} to
 * describe what is to be displayed in the screen.
 */
@Override
protected void onCreate(Bundle icicle) {
    // Be sure to call the super class.
    super.onCreate(icicle);

    // Have the system blur any windows behind this one.
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
            WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
    
    RelativeLayout container = new RelativeLayout(this);
    
    ImageButton button = new ImageButton(this);
    button.setImageResource(getIntent().getIntExtra("moodimg", 0));
    button.setOnClickListener(this);
    
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.CENTER_IN_PARENT);
    
    container.addView(button, lp);
    
    setContentView(container);
}
 
Example #14
Source File: NewFeatureActivity.java    From letv with Apache License 2.0 5 votes vote down vote up
private View getButtonView(int resId) {
    View view = this.inflater.inflate(resId, null);
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    if (metrics.widthPixels == 480) {
        ImageView imageView = (ImageView) view.findViewById(R.id.newfeatures_btn);
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
        params.bottomMargin = LiveType.PLAY_LIVE_OTHER;
        imageView.setLayoutParams(params);
    }
    return view;
}
 
Example #15
Source File: Tickmate.java    From tickmate with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_tickmate_list);

       RelativeLayout progress = new RelativeLayout(this);
       progress.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, 100));
       progress.setGravity(Gravity.CENTER);
       progress.addView(new ProgressBar(this));

       mAdapter = new InfiniteScrollAdapter<>(this,
               new TickAdapter(this, null, savedInstanceState), progress);
       mAdapter.addListener(this);

       mHandler = new Handler();

       mListHeader = (TickHeader) findViewById(R.id.list_header);
       mListHeader.initialize(this);

       mListView = (ListView) findViewById(android.R.id.list);
       mListView.setStackFromBottom(true);
       mListView.setAdapter(mAdapter);
       mListView.setOnTouchListener(mListHeader);
       mListView.getEmptyView().setOnClickListener(this);
       mListView.getEmptyView().setOnTouchListener(mListHeader);
}
 
Example #16
Source File: HorizontalImageRecyclerViewAdapter.java    From Netease with GNU General Public License v3.0 5 votes vote down vote up
ImageViewHolder(View view , int weight, int height, int i) {
    super(view);
    index = i;

    //第一张图不要边距
    if (index == 0) {
        RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,RelativeLayout.LayoutParams.MATCH_PARENT);
        RelativeLayout rv = (RelativeLayout) view.findViewById(R.id.rlContainer);
        rl.setMargins(0, 0, 0, 0);
        rv.setLayoutParams(rl);
    }
    imageView = (NetworkImageView) view.findViewById(R.id.iv_sub_image);
    imageView.setLayoutParams(new RelativeLayout.LayoutParams(weight, height));
}
 
Example #17
Source File: BaseActivity.java    From Meteorite with Apache License 2.0 5 votes vote down vote up
@Override
public void setContentView(@LayoutRes int layoutResID) {
    inflate = LayoutInflater.from(this);
    activity_base = inflate.inflate(R.layout.activity_base, null, false);
    activity = inflate.inflate(layoutResID, null, false);

    // content
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    activity.setLayoutParams(params);
    RelativeLayout mContainer = activity_base.findViewById(R.id.container);
    mContainer.addView(activity);
    getWindow().setContentView(activity_base);

    llProgressBar = getView(R.id.ll_progress_bar);
    refresh = getView(R.id.ll_error_refresh);
    ImageView img = getView(R.id.img_progress);

    // 加载动画
    mAnimationDrawable = (AnimationDrawable) img.getDrawable();
    // 默认进入页面就开启动画
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }

    if(mIsSupportToolBar){
        setToolBar();
    }else{
        toolBar = getView(R.id.tool_bar);
        toolBar.setVisibility(View.GONE);
    }

    // 点击加载失败布局
    refresh.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showLoading();
            onRefresh();
        }
    });
}
 
Example #18
Source File: RecordView.java    From RecordView with Apache License 2.0 5 votes vote down vote up
private void setMarginRight(int marginRight, boolean convertToDp) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) slideToCancelLayout.getLayoutParams();
    if (convertToDp) {
        layoutParams.rightMargin = (int) DpUtil.toPixel(marginRight, context);
    } else
        layoutParams.rightMargin = marginRight;

    slideToCancelLayout.setLayoutParams(layoutParams);
}
 
Example #19
Source File: IntroActivity.java    From SlidingIntroScreen with Apache License 2.0 5 votes vote down vote up
/**
 * Binds the View elements used in this activity to member variables.
 */
private void bindViews() {
	rootView = (RelativeLayout) findViewById(R.id.intro_activity_root);
	horizontalDivider = findViewById(R.id.intro_activity_horizontalDivider);
	viewPager = (LockableViewPager) findViewById(R.id.intro_activity_viewPager);
	progressIndicatorWrapper =
			(FrameLayout) findViewById(R.id.intro_activity_progressIndicatorHolder);
	leftButton = (IntroButton) findViewById(R.id.intro_activity_leftButton);
	rightButton = (IntroButton) findViewById(R.id.intro_activity_rightButton);
	finalButton = (IntroButton) findViewById(R.id.intro_activity_finalButton);
}
 
Example #20
Source File: TargetAppCompatActivity.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, TAG + ":onCreate");

    RelativeLayout relativeLayout = new RelativeLayout(this);
    relativeLayout.setGravity(Gravity.CENTER);

    TextView textView = new TextView(this);
    textView.setText("未注册的TargetAppCompatActivity,成功!");

    relativeLayout.addView(textView);
    setContentView(relativeLayout);
}
 
Example #21
Source File: FloatingFoldersViewHolder.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
@Override public void bind(@NonNull FolderModel folderModel) {
    TextDrawable.IBuilder builder = TextDrawable.builder()
            .beginConfig()
            .endConfig()
            .round();
    String letter = InputHelper.getTwoLetters(folderModel.getFolderName());
    int color = folderModel.getColor() == 0 ? ColorGenerator.MATERIAL.getRandomColor() : folderModel.getColor();
    imageIcon.setImageDrawable(builder.build(letter.toUpperCase(), color));
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageIcon.getLayoutParams();
    int gap = PrefConstant.getGapSize(imageIcon.getResources());
    if (!isHorizontal) params.setMargins(0, 0, 0, gap);
    else params.setMargins(0, 0, gap, 0);
}
 
Example #22
Source File: EmoticonsIndicatorView.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void reset(int count) {

        Log.e("APP", "EmoticonsIndicatorView init,  count:" + count);

//        if (mImageViews != null) {
//            return;
//        }

        if (mImageViews != null) {
            this.removeAllViews();
        }
        mImageViews = new ArrayList<ImageView>();
        for (int i = 0; i < count; i++) {
            RelativeLayout rl = new RelativeLayout(mContext);
            LayoutParams params = new LinearLayout.LayoutParams(mMaxHeight, mMaxHeight);
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
            layoutParams.addRule(ResizeLayout.CENTER_IN_PARENT);
            ImageView imageView = new ImageView(mContext);

            if (i == 0) {
                imageView.setImageBitmap(bmpSelect);
                rl.addView(imageView, layoutParams);
            } else {
                imageView.setImageBitmap(bmpNomal);
                rl.addView(imageView, layoutParams);
            }
            this.addView(rl, params);
            mImageViews.add(imageView);
        }
    }
 
Example #23
Source File: ChannelTabPageIndicator.java    From letv with Apache License 2.0 5 votes vote down vote up
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (item != -1 || this.mSelectedTabIndex != item) {
            this.mSelectedTabIndex = item;
            int tabCount = this.mTabLayout.getChildCount();
            for (int i = 0; i < tabCount; i++) {
                RelativeLayout childLayout = (RelativeLayout) this.mTabLayout.getChildAt(i);
                for (int j = 0; j < childLayout.getChildCount(); j++) {
                    boolean isSelected;
                    if (i == item) {
                        isSelected = true;
                    } else {
                        isSelected = false;
                    }
                    View view = childLayout.getChildAt(j);
                    if (view instanceof TabView) {
                        view.setSelected(isSelected);
                        if (isSelected) {
                            animateToTab(item);
                        }
                    } else {
                        view.setSelected(isSelected);
                    }
                }
            }
            this.mViewPager.setCurrentItem(item, false);
        }
    }
}
 
Example #24
Source File: ConvenientBanner.java    From AndroidBase with Apache License 2.0 5 votes vote down vote up
/**
 * 指示器的方向
 *
 * @param align 三个方向:居左 (RelativeLayout.ALIGN_PARENT_LEFT),居中 (RelativeLayout.CENTER_HORIZONTAL),居右 (RelativeLayout.ALIGN_PARENT_RIGHT)
 * @return
 */
public ConvenientBanner setPageIndicatorAlign(PageIndicatorAlign align) {
    RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) loPageTurningPoint.getLayoutParams();
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT, align == PageIndicatorAlign.ALIGN_PARENT_LEFT ? RelativeLayout.TRUE : 0);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, align == PageIndicatorAlign.ALIGN_PARENT_RIGHT ? RelativeLayout.TRUE : 0);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, align == PageIndicatorAlign.CENTER_HORIZONTAL ? RelativeLayout.TRUE : 0);
    loPageTurningPoint.setLayoutParams(layoutParams);
    return this;
}
 
Example #25
Source File: WebViewActivity.java    From ByWebView with Apache License 2.0 5 votes vote down vote up
private void initTitle() {
    StatusBarUtil.setColor(this, ContextCompat.getColor(this, R.color.colorPrimary), 0);
    RelativeLayout rl_web_container = findViewById(R.id.rl_web_container);
    webView = new WebView(this);
    mProgressBar = new WebProgress(this);
    mProgressBar.setVisibility(View.GONE);
    rl_web_container.addView(webView, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    rl_web_container.addView(mProgressBar);
    mProgressBar.setColor(ContextCompat.getColor(this, R.color.colorAccent));
    mProgressBar.show();
    initToolBar();
}
 
Example #26
Source File: EditPageLand.java    From BaoKanAndroid with MIT License 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = ResHelper.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example #27
Source File: DefaultHeaderTransformer.java    From Bitocle with Apache License 2.0 5 votes vote down vote up
private void applyProgressBarStyle() {
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, mProgressBarHeight);

    switch (mProgressBarStyle) {
        case PROGRESS_BAR_STYLE_INSIDE:
            lp.addRule(RelativeLayout.ALIGN_BOTTOM, R.id.ptr_content);
            break;
        case PROGRESS_BAR_STYLE_OUTSIDE:
            lp.addRule(RelativeLayout.BELOW, R.id.ptr_content);
            break;
    }

    mHeaderProgressBar.setLayoutParams(lp);
}
 
Example #28
Source File: SamplePugNotification.java    From Pugnotification with Apache License 2.0 5 votes vote down vote up
private void loadInfoComponents() {
    this.mEdtTitle = (EditText) findViewById(R.id.edt_title);
    this.mEdtMessage = (EditText) findViewById(R.id.edt_message);
    this.mEdtBigText = (EditText) findViewById(R.id.edt_bigtext);
    this.mEdtUrl = (EditText) findViewById(R.id.edt_url);
    this.mBtnNotifySimple = (Button) findViewById(R.id.btn_notify_simple);
    this.mBtnNotifyCustom = (Button) findViewById(R.id.btn_notify_custom);
    this.mSpnType = (Spinner) findViewById(R.id.spn_notification_type);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.pugnotification_notification_types, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    this.mSpnType.setAdapter(adapter);

    this.mContentBigText = (RelativeLayout) findViewById(R.id.content_bigtext);
}
 
Example #29
Source File: EditPageLand.java    From enjoyshop with Apache License 2.0 5 votes vote down vote up
public void onCreate() {
	super.onCreate();

	int screenHeight = ResHelper.getScreenHeight(activity);
	float ratio = ((float) screenHeight) / DESIGN_SCREEN_WIDTH;

	maxBodyHeight = 0;

	llPage = new LinearLayout(activity);
	llPage.setOrientation(LinearLayout.VERTICAL);
	activity.setContentView(llPage);

	rlTitle = new RelativeLayout(activity);
	rlTitle.setBackgroundColor(0xffe6e9ec);
	int titleHeight = (int) (DESIGN_TITLE_HEIGHT_L * ratio);

	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, titleHeight);
	llPage.addView(rlTitle, lp);
	initTitle(rlTitle, ratio);

	RelativeLayout rlBody = new RelativeLayout(activity);
	rlBody.setBackgroundColor(0xffffffff);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(rlBody, lp);
	initBody(rlBody, ratio);

	LinearLayout llShadow = new LinearLayout(activity);
	llShadow.setOrientation(LinearLayout.VERTICAL);
	rlBody.addView(llShadow, new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
	initShadow(llShadow, ratio);

	llBottom = new LinearLayout(activity);
	llBottom.setOrientation(LinearLayout.VERTICAL);
	lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
	llPage.addView(llBottom, lp);
	initBottom(llBottom, ratio);
}
 
Example #30
Source File: Slider.java    From DMAudioStreamer with Apache License 2.0 5 votes vote down vote up
protected void setAttributes(AttributeSet attrs) {

        setBackgroundResource(R.drawable.background_transparent);

        // Set size of view
        setMinimumHeight(dpToPx(48, getResources()));
        setMinimumWidth(dpToPx(80, getResources()));

        // Set background Color
        // Color by resource
        int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1);
        if (bacgroundColor != -1) {
            setBackgroundColor(getResources().getColor(bacgroundColor));
        } else {
            // Color by hexadecimal
            int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
            if (background != -1)
                setBackgroundColor(background);
        }

        min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
        max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 0);
        value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);

        ball = new Ball(getContext());
        LayoutParams params = new LayoutParams(dpToPx(15, getResources()), dpToPx(15, getResources()));
        params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        ball.setLayoutParams(params);
        addView(ball);

    }