Java Code Examples for android.widget.ImageButton#getLayoutParams()
The following examples show how to use
android.widget.ImageButton#getLayoutParams() .
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: FakeFabInteractiveActivity.java From MaterialDesignDemo with MIT License | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fake_fab_interactive); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); mRv = (RecyclerView) findViewById(R.id.rv); mFab = (ImageButton) findViewById(R.id.fab); mToolbarBottomMargin = ((ViewGroup.MarginLayoutParams) mToolbar.getLayoutParams()).bottomMargin; mFabBottomMargin = ((ViewGroup.MarginLayoutParams) mFab.getLayoutParams()).bottomMargin; mRv.setLayoutManager(new LinearLayoutManager(this)); mRv.setAdapter(new MyAdapter(mData)); mRv.addOnScrollListener(new FakeFabScrollListener(this)); }
Example 2
Source File: FeedDetailActivity.java From umeng_community_android with MIT License | 6 votes |
@SuppressWarnings("deprecation") private void initTitleLayout() { TextView titleTextView = (TextView) findViewById(ResFinder.getId( "umeng_comm_title_tv")); titleTextView.setText(ResFinder.getString("umeng_comm_feed_detail")); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18); // back btn findViewById(ResFinder.getId("umeng_comm_title_back_btn")).setOnClickListener(this); // 刷新按钮 mRefreshButton = (ImageButton) findViewById(ResFinder.getId( "umeng_comm_title_setting_btn")); LayoutParams layoutParams = (LayoutParams) mRefreshButton.getLayoutParams(); layoutParams.width = DeviceUtils.dp2px(this, 20); layoutParams.height = DeviceUtils.dp2px(this, 20); layoutParams.rightMargin = DeviceUtils.dp2px(getApplicationContext(), 4); mRefreshButton.setLayoutParams(layoutParams); mRefreshButton.setBackgroundDrawable(ResFinder.getDrawable("umeng_comm_more")); mRefreshButton.setOnClickListener(new LoginOnViewClickListener() { @Override protected void doAfterLogin(View v) { mActionDialog.show(); } }); }
Example 3
Source File: EnterPasswordActivity.java From TuentiTV with Apache License 2.0 | 5 votes |
private void showPasswordElement(int passwordElementResource) { ImageButton ib_password_element = (ImageButton) getCurrentFocus(); ib_password_element.setImageResource(passwordElementResource); ib_password_element.setBackgroundResource(R.color.transparent); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) ib_password_element.getLayoutParams(); lp.height = LinearLayout.LayoutParams.WRAP_CONTENT; ib_password_element.setLayoutParams(lp); updatePasswordElementWithAsterisk(ib_password_element, CHANGE_PASSWORD_TIME_IN_MILLIS); }
Example 4
Source File: AudioPlayActivity.java From react-native-voice-recorder with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(cafe.adriel.androidaudiorecorder.R.layout.aar_activity_audio_recorder); if(savedInstanceState != null) { filePath = savedInstanceState.getString(AudioPlay.EXTRA_FILE_PATH); source = (AudioSource) savedInstanceState.getSerializable(AudioPlay.EXTRA_SOURCE); channel = (AudioChannel) savedInstanceState.getSerializable(AudioPlay.EXTRA_CHANNEL); sampleRate = (AudioSampleRate) savedInstanceState.getSerializable(AudioPlay.EXTRA_SAMPLE_RATE); color = savedInstanceState.getInt(AudioPlay.EXTRA_COLOR); autoStart = savedInstanceState.getBoolean(AudioPlay.EXTRA_AUTO_START); keepDisplayOn = savedInstanceState.getBoolean(AudioPlay.EXTRA_KEEP_DISPLAY_ON); } else { filePath = getIntent().getStringExtra(AudioPlay.EXTRA_FILE_PATH); source = (AudioSource) getIntent().getSerializableExtra(AudioPlay.EXTRA_SOURCE); channel = (AudioChannel) getIntent().getSerializableExtra(AudioPlay.EXTRA_CHANNEL); sampleRate = (AudioSampleRate) getIntent().getSerializableExtra(AudioPlay.EXTRA_SAMPLE_RATE); color = getIntent().getIntExtra(AudioPlay.EXTRA_COLOR, Color.BLACK); autoStart = getIntent().getBooleanExtra(AudioPlay.EXTRA_AUTO_START, false); keepDisplayOn = getIntent().getBooleanExtra(AudioPlay.EXTRA_KEEP_DISPLAY_ON, false); } if(keepDisplayOn){ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); } if (getSupportActionBar() != null) { getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setElevation(0); getSupportActionBar().setBackgroundDrawable( new ColorDrawable(Util.getDarkerColor(color))); getSupportActionBar().setHomeAsUpIndicator( ContextCompat.getDrawable(this, cafe.adriel.androidaudiorecorder.R.drawable.aar_ic_clear)); } visualizerView = new GLAudioVisualizationView.Builder(this) .setLayersCount(1) .setWavesCount(6) .setWavesHeight(cafe.adriel.androidaudiorecorder.R.dimen.aar_wave_height) .setWavesFooterHeight(cafe.adriel.androidaudiorecorder.R.dimen.aar_footer_height) .setBubblesPerLayer(20) .setBubblesSize(cafe.adriel.androidaudiorecorder.R.dimen.aar_bubble_size) .setBubblesRandomizeSize(true) .setBackgroundColor(Util.getDarkerColor(color)) .setLayerColors(new int[]{color}) .build(); contentLayout = (RelativeLayout) findViewById(cafe.adriel.androidaudiorecorder.R.id.content); statusView = (TextView) findViewById(cafe.adriel.androidaudiorecorder.R.id.status); timerView = (TextView) findViewById(cafe.adriel.androidaudiorecorder.R.id.timer); restartView = (ImageButton) findViewById(cafe.adriel.androidaudiorecorder.R.id.restart); recordView = (ImageButton) findViewById(R.id.record); playView = (ImageButton) findViewById(cafe.adriel.androidaudiorecorder.R.id.play); contentLayout.setBackgroundColor(Util.getDarkerColor(color)); contentLayout.addView(visualizerView, 0); restartView.setVisibility(View.INVISIBLE); recordView.setVisibility(View.INVISIBLE); playView.setVisibility(View.VISIBLE); ((ViewGroup) restartView.getParent()).removeView(restartView); ((ViewGroup) recordView.getParent()).removeView(recordView); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) playView.getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); if(Util.isBrightColor(color)) { ContextCompat.getDrawable(this, cafe.adriel.androidaudiorecorder.R.drawable.aar_ic_clear) .setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); ContextCompat.getDrawable(this, cafe.adriel.androidaudiorecorder.R.drawable.aar_ic_check) .setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP); statusView.setTextColor(Color.BLACK); timerView.setTextColor(Color.BLACK); restartView.setColorFilter(Color.BLACK); recordView.setColorFilter(Color.BLACK); playView.setColorFilter(Color.BLACK); } }
Example 5
Source File: LauncherShortcutConfirmAndGenerateActivity.java From FreezeYou with Apache License 2.0 | 4 votes |
private void processChangeIconImageButton(String pkgName, ImageButton lscaga_icon_imageButton) { int widthAndHeight = (int) (getResources().getDisplayMetrics().widthPixels * 0.35); if (widthAndHeight <= 0) widthAndHeight = 1; ViewGroup.LayoutParams layoutParams = lscaga_icon_imageButton.getLayoutParams(); layoutParams.height = widthAndHeight; layoutParams.width = widthAndHeight; lscaga_icon_imageButton.setLayoutParams(layoutParams); if (pkgName != null) { switch (pkgName) { case "cf.playhi.freezeyou.extra.fuf": case "OF": case "UF": case "OO": case "OOU": case "FOQ": finalDrawable = getResources().getDrawable(R.mipmap.ic_launcher_round); break; case "cf.playhi.freezeyou.extra.oklock": finalDrawable = getResources().getDrawable(R.drawable.screenlock); break; default: finalDrawable = getString(R.string.plsSelect).equals(pkgName) ? getResources().getDrawable(R.drawable.grid_add) : getApplicationIcon( this, pkgName, ApplicationInfoUtils.getApplicationInfoFromPkgName(pkgName, this), false ); break; } lscaga_icon_imageButton.setImageDrawable(finalDrawable); lscaga_icon_imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivityForResult( new Intent(LauncherShortcutConfirmAndGenerateActivity.this, SelectShortcutIconActivity.class), 21); } }); } }
Example 6
Source File: ExoPlayerWrapperView.java From RedReader with GNU General Public License v3.0 | 3 votes |
private static void addButton(final ImageButton button, final LinearLayout layout) { layout.addView(button); final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) button.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; }