下面列出了android.view.animation.LinearInterpolator#android.widget.RelativeLayout 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
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));
}
}
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);
}
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);
}
/**
* 设置导航条颜色
* @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);
}
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);
}
});
}
/**
* 获取头部视图
*
* @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;
}
@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);
}
@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);
}
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);
}
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);
}
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);
}
public void initViews(View rootView) {
this.handleView = rootView.findViewById(R.id.camera_params_setting);
this.tabHost = (X8TabHost) rootView.findViewById(R.id.camera_tab);
this.isoRecycler = (RecyclerView) rootView.findViewById(R.id.iso_recycler);
this.shutterRecycler = (RecyclerView) rootView.findViewById(R.id.shutter_recycler);
this.rulerView = (X8RulerView) rootView.findViewById(R.id.rulerView);
this.tvEv = (TextView) rootView.findViewById(R.id.ev_value);
this.shutterView = (RelativeLayout) rootView.findViewById(R.id.shutter_layout);
this.tvIso = (TextView) rootView.findViewById(R.id.iso_title);
this.tvShutter = (TextView) rootView.findViewById(R.id.shutter_title);
this.isoView = (RelativeLayout) rootView.findViewById(R.id.iso_layout);
this.evView = (RelativeLayout) rootView.findViewById(R.id.ev_layout);
this.ev_add_btn = (TextView) rootView.findViewById(R.id.ev_add_btn);
this.ev_reduct_btn = (TextView) rootView.findViewById(R.id.ev_reduce_btn);
this.layoutManager = new LinearLayoutManager(this.mContext);
this.layoutManager.setOrientation(0);
this.isoRecycler.setLayoutManager(this.layoutManager);
this.isoRecycler.setHasFixedSize(true);
this.isoRecycler.setAnimation(null);
this.shutterLayout = new LinearLayoutManager(this.mContext);
this.shutterLayout.setOrientation(0);
this.shutterRecycler.setLayoutManager(this.shutterLayout);
this.shutterRecycler.setHasFixedSize(true);
this.shutterRecycler.setAnimation(null);
this.ev_reduct_btn.setOnClickListener(this);
this.ev_add_btn.setOnClickListener(this);
}
@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);
}
public T addRule(Integer verb, Integer rule) {
if (null == relativeParams) {
relativeParams = new RelativeLayout.LayoutParams(wrapContent, wrapContent);
}
relativeParams.addRule(verb, rule);
return self();
}
private void playVideo(File videoFile) {
mVideoView.setVideoPath(videoFile.getPath());
mVideoView.setLayoutParams(new RelativeLayout.LayoutParams(-1, -1));
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setLooping(true);
mediaPlayer.start();
}
});
}
/**
* 布局到顶部
*/
@Override
public void contentLayoutToTop() {
if (scrollRunning || MainActivity.isMenuVisible()) {
return;
}
if (runnableTop != null) {
contentLayoutToTopListener(true);
handler.post(runnableTop);
return;
}
runnableTop = new Runnable() {
@Override
public void run() {
if (params == null) {
params = (RelativeLayout.LayoutParams) dl3.getLayoutParams();
oldTopMargin = params.topMargin;
minTopMargin = appbar.getHeight();
}
if (params.topMargin > minTopMargin) {
params.topMargin -= 30;
dl3.setLayoutParams(params);
handler.post(this);
} else {
imgScrollInfo.setImageResource(R.drawable.ic_scroll_down);
handler.removeCallbacks(this);
contentLayoutToTopListener(false);
}
}
};
contentLayoutToTopListener(true);
handler.post(runnableTop);
}
public FriendHolder(View itemView) {
super(itemView);
contentLayout = (RelativeLayout) itemView.findViewById(R.id.content_layout);
deleteTv = (ImageView) itemView.findViewById(R.id.delete_tv);
avater = (RoundedImageView) itemView.findViewById(R.id.avater_rimg);
name = (TextView)itemView.findViewById(R.id.name_tv);
((SideScrollView) itemView).setSideScrollListener(sideScrollListener);
}
/**
* Called when the user selects "Load Sketch" - this will open the navigation drawer
*/
private void loadSketch() {
//Opens the navigation drawer
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer);
RelativeLayout drawerLayout = (RelativeLayout) findViewById(R.id.drawer_wrapper);
drawer.openDrawer(drawerLayout);
}
/**
* 设置Y坐标
*
* @param y
* @return
*/
public UDView setY(int y) {
View view = getView();
if (view != null) {
if (view.getLayoutParams() instanceof RelativeLayout.LayoutParams) {
RelativeLayout.LayoutParams layoutParams =
(RelativeLayout.LayoutParams) view.getLayoutParams();
layoutParams.topMargin = y;
view.setLayoutParams(layoutParams);
}
}
return this;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mContainerGroupLayout = (RelativeLayout) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);
setupModeSelectListView();
setupPageSelectListView();
return mContainerGroupLayout;
}
public static View createSimpleLoadingTip(Context context) {
final View view = LayoutInflater.from(context).inflate(R.layout.cube_ptr_simple_loading, null);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(-2, -2);
lp.setMargins(0, 0, 0, LocalDisplay.dp2px(4));
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
lp.addRule(RelativeLayout.CENTER_VERTICAL);
view.setLayoutParams(lp);
view.setVisibility(View.INVISIBLE);
return view;
}
@Override
protected void createLayout() {
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
final ViewGroup mainView = (ViewGroup) inflater.inflate(R.layout.activity_base, null, false);
View contentView = inflater.inflate(getLayout(), mainView, false);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
params.addRule(RelativeLayout.BELOW, R.id.toolbar_main);
contentView.setLayoutParams(params);
mainView.addView(contentView, 0);
setContentView(mainView);
}
private void init(Context context) {
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 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);
}
/**
* 动态添加多图裁剪底部预览图片列表
*/
private void addPhotoRecyclerView() {
mRecyclerView = new RecyclerView(this);
mRecyclerView.setId(R.id.id_recycler);
mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
RelativeLayout.LayoutParams lp =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, dip2px(80));
mRecyclerView.setLayoutParams(lp);
LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
mRecyclerView.setLayoutManager(mLayoutManager);
resetCutDataStatus();
list.get(cutIndex).setCut(true);
adapter = new PicturePhotoGalleryAdapter(this, list);
mRecyclerView.setAdapter(adapter);
adapter.setOnItemClickListener((position, view) -> {
if (cutIndex == position) {
return;
}
cutIndex = position;
resetCutData();
});
uCropMultiplePhotoBox.addView(mRecyclerView);
changeLayoutParams();
FrameLayout uCropFrame = findViewById(R.id.ucrop_frame);
((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams())
.addRule(RelativeLayout.ABOVE, R.id.id_recycler);
}
public PromptDialog(Context context) {
super(context);
finder = ResoureFinder.getInstance(context);
final LayoutInflater inflater = LayoutInflater.from(getContext());
final RelativeLayout layout = (RelativeLayout) inflater.inflate(
finder.getLayoutId("platform_window_dialog_prompt_layout"), null);
tvDesc = (TextView) layout.findViewById(finder.getId("tv_dialog_input_desc"));
etInput = (EditText) layout.findViewById(finder.getId("et_dialog_input_text"));
etInput.setSelectAllOnFocus(true);
setView(layout);
}
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);
}
private void showCloudOfflineBanner(DeviceControlCard card) {
View banner = findViewById(R.id.card_device_bottom_part);
banner.setVisibility(View.VISIBLE);
banner.setBackgroundColor(getResources().getColor(R.color.pink_banner));
View waiting = findViewById(R.id.waiting_on_label_device_list);
if(card.isIsEventInProcess()) {
waiting.setVisibility(View.VISIBLE);
}
else {
waiting.setVisibility(View.GONE);
}
if(card.getDeviceId() !=null) {
final DeviceModel model = SessionModelManager.instance().getDeviceWithId(card.getDeviceId(), false);
if (model != null) {
ImageView icon = (ImageView) findViewById(R.id.product_icon);
String vendorName = String.valueOf(model.getVendor()).toUpperCase();
ImageManager.with(getContext())
.putBrandImage(vendorName)
.withTransform(new BlackWhiteInvertTransformation(Invert.BLACK_TO_WHITE))
.into(icon)
.execute();
}
}
RelativeLayout offlineBanner = (RelativeLayout) findViewById(R.id.device_offline_banner);
offlineBanner.setVisibility(INVISIBLE);
setBackgroundColor(getContext().getResources().getColor(R.color.cardview_dark_background));
hideControls();
}
protected void dialogAdjustment(Dialog dialog) {
dialog.findViewById(R.id.btnSave2).setVisibility(View.GONE);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) btnMap.getLayoutParams();
params.addRule(RelativeLayout.LEFT_OF, 0);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
btnMap.setLayoutParams(params); //causes layout update
}
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;
});
}