List of usage examples for android.widget RelativeLayout CENTER_HORIZONTAL
int CENTER_HORIZONTAL
To view the source code for android.widget RelativeLayout CENTER_HORIZONTAL.
Click Source Link
From source file:com.spoiledmilk.ibikecph.navigation.SMRouteNavigationActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.route_navigation_activity); LayoutInflater inflater = LayoutInflater.from(this); reportProblemsView = (RelativeLayout) inflater.inflate(R.layout.report_problems_view, null); textReport = (TextView) reportProblemsView.findViewById(R.id.textReport); instructionsViewMaxContainer = (RelativeLayout) findViewById(R.id.instructionsViewMaxContainer); paramsForInstMaxContainer = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); paramsForInstMaxContainer.addRule(RelativeLayout.ALIGN_PARENT_TOP); paramsForInstMaxContainer.addRule(RelativeLayout.CENTER_HORIZONTAL); paramsForInstMaxContainer.topMargin = 0; instructionsViewMaxContainer.setLayoutParams(paramsForInstMaxContainer); routeFinishedContainer = (RelativeLayout) findViewById(R.id.routeFinishedContainer); imgClose = (ImageButton) findViewById(R.id.imgClose); imgClose.setOnClickListener(new OnClickListener() { @Override/* w w w . ja v a 2s . c om*/ public void onClick(View arg0) { Bundle conData = new Bundle(); conData.putInt("overlaysShown", getOverlaysShown()); Intent intent = new Intent(); intent.putExtras(conData); setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION, intent); setResult(MapActivity.RESULT_RETURN_FROM_NAVIGATION); finish(); overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right); } }); progressBar = (ProgressBar) findViewById(R.id.progressBar); textGoodRide = (TextView) findViewById(R.id.textGoodRide); textRecalculating = (TextView) findViewById(R.id.textRecalculating); textBicycle = (TextView) findViewById(R.id.textBicycle); textCargo = (TextView) findViewById(R.id.textCargo); textGreen = (TextView) findViewById(R.id.textGreen); FrameLayout.LayoutParams rootParams = new FrameLayout.LayoutParams((int) (9 * Util.getScreenWidth() / 5), FrameLayout.LayoutParams.MATCH_PARENT); findViewById(R.id.root_layout).setLayoutParams(rootParams); this.maxSlide = (int) (4 * Util.getScreenWidth() / 5); Util.init(getWindowManager()); leftContainer = (RelativeLayout) findViewById(R.id.leftContainer); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth() * 4 / 5, RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); leftContainer.setLayoutParams(params); parentContainer = (RelativeLayout) findViewById(R.id.parent_container); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.MATCH_PARENT); params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); params.addRule(RelativeLayout.ALIGN_PARENT_TOP); parentContainer.setLayoutParams(params); imgCargoSlider = (ImageView) findViewById(R.id.imgCargoSlider); imgCargoSlider.setOnTouchListener(new OnTouchListener() { // Swipe the view horizontally @Override public boolean onTouch(View v, MotionEvent event) { return onSliderTouch(v, event); } }); darkenedView = findViewById(R.id.darkenedView); darkenedView.setBackgroundColor(Color.BLACK); viewDistance = (RelativeLayout) findViewById(R.id.viewDistance); textTime = (TextView) findViewById(R.id.textTime); mapDisabledView = findViewById(R.id.mapDisabledView); mapDisabledView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // used to disable the map touching when sliden return onSliderTouch(v, event); } }); paramsInstructionsMaxNormal.topMargin = (int) (Util.getScreenHeight() - Util.dp2px(146)); paramsInstructionsMaxNormal.bottomMargin = -(int) ((Util.getScreenHeight())); paramsInstructionsMaxMaximized.topMargin = INSTRUCTIONS_TOP_MARGIN; paramsInstructionsMaxMinimized.topMargin = (int) (Util.getScreenHeight() - Util.getScreenHeight() / 10); paramsInstructionsMaxMinimized.bottomMargin = -(int) ((Util.getScreenHeight())); overviewLayout = (RelativeLayout) findViewById(R.id.overviewLayout); btnStart = (Button) overviewLayout.findViewById(R.id.btnStart); btnStart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewDistance.setVisibility(View.VISIBLE); btnStart.setEnabled(false); hideOverview(); textTime.setText(mapFragment.getEstimatedArrivalTime()); mapFragment.startRouting(); IbikeApplication.getTracker().sendEvent("Route", "Overview", mapFragment.destination, (long) 0); // instructionsView.setVisibility(View.VISIBLE); setInstructionViewState(InstrcutionViewState.Normal); RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10)); paramsBtnTrack.alignWithParent = true; paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsBtnTrack.addRule(RelativeLayout.ABOVE, instructionsView.getId()); btnTrack.setLayoutParams(paramsBtnTrack); startTrackingUser(); } }); btnClose = ((ImageButton) findViewById(R.id.btnClose)); btnClose.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showStopDlg(); } }); // Darken the button on touch : btnClose.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent me) { if (me.getAction() == MotionEvent.ACTION_DOWN) { btnClose.setColorFilter(Color.argb(150, 155, 155, 155)); return false; } else if (me.getAction() == MotionEvent.ACTION_UP || me.getAction() == MotionEvent.ACTION_CANCEL) { btnClose.setColorFilter(Color.argb(0, 155, 155, 155)); return false; } return false; } }); // increased touch area for the normal pull handle pullTouchNormal = findViewById(R.id.pullTouchNormal); pullTouchNormal.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = true; return onPullHandleTouch(null, event); } }); // increased touch area for the max pull handle pullTouchMax = findViewById(R.id.pullTouchMax); pullTouchMax.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = false; yFix = Util.dp2px(16); return onPullHandleTouch(null, event); } }); mapTopDisabledView = findViewById(R.id.mapTopDisabledView); mapTopDisabledView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = false; yFix = Util.dp2px(42); // return onPullHandleTouch(null, event); return true; } }); instructionsView = (RelativeLayout) findViewById(R.id.instructionsView); instructionsView.setBackgroundColor(Color.BLACK); pullHandle = (ImageButton) instructionsView.findViewById(R.id.imgPullHandle); pullHandle.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent event) { isPulledFromNormal = true; return onPullHandleTouch(null, event); } }); instructionsViewMin = (LinearLayout) findViewById(R.id.instructionsViewMin); pullHandleMin = (ImageButton) instructionsViewMin.findViewById(R.id.imgPullHandleMin); pullHandleMin.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { return onPullHandleTouch(arg0, arg1); } }); instructionsViewMax = (RelativeLayout) findViewById(R.id.instructionsViewMax); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); instructionsView.setLayoutParams(params); params = new RelativeLayout.LayoutParams((int) Util.getScreenWidth(), RelativeLayout.LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); findViewById(R.id.overviewLayout).setLayoutParams(params); pullHandleMax = (ImageButton) instructionsViewMax.findViewById(R.id.imgPullHandleMax); pullHandleMax.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View arg0, MotionEvent arg1) { isPulledFromNormal = false; return onPullHandleTouch(arg0, arg1); } }); instructionList = (ListView) instructionsViewMax.findViewById(R.id.listView); instructionList.addFooterView(reportProblemsView); setInstructionViewState(InstrcutionViewState.Invisible); FragmentManager fm = this.getSupportFragmentManager(); mapFragment = getMapFragment(); fm.beginTransaction().add(R.id.map_container, mapFragment).commit(); viewPager = (ViewPager) instructionsView.findViewById(R.id.viewPager); // viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { if (!instructionsUpdated || (mapFragment.isRecalculation && !mapFragment.getTrackingMode())) { SMTurnInstruction turn = mapFragment.route.getTurnInstructions().get(position); if (turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachedYourDestination || turn.drivingDirection == SMTurnInstruction.TurnDirection.ReachingDestination) { mapFragment.animateTo(mapFragment.route.getEndLocation()); } else { mapFragment.animateTo(turn.getLocation()); } stopTrackingUser(); } } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); pagerAdapter = getPagerAdapter(); viewPager.setAdapter(pagerAdapter); viewPager.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // used to disable viewPager swiping when the left menu is // opened return slidden; } }); btnTrack = (ImageButton) findViewById(R.id.btnTrack); btnTrack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!mapFragment.getTrackingMode()) { startTrackingUser(); } else { mapFragment.switchTracking(); changeTrackingIcon(); } } }); textReport.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchReportIssuesActivity(); } }); textReport2 = (TextView) findViewById(R.id.textReport2); textReport2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { launchReportIssuesActivity(); } }); textDestAddress = (TextView) findViewById(R.id.textDestAddress); textDestAddress.setTypeface(IbikeApplication.getNormalFont()); Config.OSRM_SERVER = Config.OSRM_SERVER_FAST; if (savedInstanceState != null) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Intent intent = new Intent(SMRouteNavigationActivity.this, getSplashActivityClass()); intent.putExtra("timeout", 0); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }, 400); } instructionsViewMax.setLayoutParams(paramsInstructionsMaxNormal); RelativeLayout.LayoutParams paramsBtnTrack = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsBtnTrack.setMargins(Util.dp2px(10), Util.dp2px(10), Util.dp2px(10), Util.dp2px(10)); paramsBtnTrack.alignWithParent = true; paramsBtnTrack.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); paramsBtnTrack.addRule(RelativeLayout.ABOVE, overviewLayout.getId()); btnTrack.setLayoutParams(paramsBtnTrack); instructionsView.measure(0, 0); instructionsViewHeight = instructionsView.getMeasuredHeight(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.example.de.taomi2.mediachooser.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }// w w w .java 2s .com if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.learnncode.mediachooser.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }/*from w w w. j a v a 2s. c o m*/ if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) textView .getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (android.widget.LinearLayout.LayoutParams) textView .getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (android.widget.RelativeLayout.LayoutParams) headerBarCamera .getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(this); headerBarCamera.setOnClickListener(this); headerBarDone.setOnClickListener(this); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); }/*from www . j av a 2s.c o m*/ if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(Utils.convertDipToPixels(this, 10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = Utils.convertDipToPixels(this, 40); params.width = Utils.convertDipToPixels(this, 40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15), Utils.convertDipToPixels(this, 15)); }
From source file:es.eucm.eadandroid.utils.ViewPagerIndicator.java
/** * Create all views, build the layout//from w ww . ja v a2s .c o m */ private void addContent() { mFocusedTextColor = new int[] { 0, 0, 0 }; mUnfocusedTextColor = new int[] { 225, 225, 225 }; // Text views mPrevious = new TextView(getContext()); mCurrent = new TextView(getContext()); mNext = new TextView(getContext()); RelativeLayout.LayoutParams previousParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); previousParams.addRule(RelativeLayout.ALIGN_LEFT); RelativeLayout.LayoutParams currentParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); currentParams.addRule(RelativeLayout.CENTER_HORIZONTAL); RelativeLayout.LayoutParams nextParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); nextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // Groups holding text and arrows mPreviousGroup = new LinearLayout(getContext()); mPreviousGroup.setOrientation(LinearLayout.HORIZONTAL); mNextGroup = new LinearLayout(getContext()); mNextGroup.setOrientation(LinearLayout.HORIZONTAL); mPreviousGroup.addView(mPrevious, new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); mNextGroup.addView(mNext, new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); addView(mPreviousGroup, previousParams); addView(mCurrent, currentParams); addView(mNextGroup, nextParams); mPrevious.setSingleLine(); mCurrent.setSingleLine(); mNext.setSingleLine(); mPrevious.setText("previous"); mCurrent.setText("current"); mNext.setText("next"); // Set colors mNext.setTextColor(Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2])); mPrevious.setTextColor( Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2])); updateColor(0); }
From source file:mediachooser.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(getRLayoutId("activity_home_media_chooser")); maxImages = getIntent().getIntExtra(MultiImageChooserActivity.MAX_IMAGES_KEY, MultiImageChooserActivity.NOLIMIT); desiredWidth = getIntent().getIntExtra(MultiImageChooserActivity.WIDTH_KEY, 0); desiredHeight = getIntent().getIntExtra(MultiImageChooserActivity.HEIGHT_KEY, 0); quality = getIntent().getIntExtra(MultiImageChooserActivity.QUALITY_KEY, 0); thumbSize = getIntent().getIntExtra(MultiImageChooserActivity.THUMB_SIZE_KEY, 0); maxImageCount = maxImages;/*from w w w. j a v a 2s . co m*/ headerBarTitle = (TextView) findViewById(getRIntId("titleTextViewFromMediaChooserHeaderBar")); headerBarCamera = (ImageView) findViewById(getRIntId("cameraImageViewFromMediaChooserHeaderBar")); headerBarBack = (ImageView) findViewById(getRIntId("backArrowImageViewFromMediaChooserHeaderView")); headerBarDone = (TextView) findViewById(getRIntId("doneTextViewViewFromMediaChooserHeaderView")); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); leftLinearContainer = (LinearLayout) findViewById(getRIntId("leftLinearContainer")); mTabHost.setup(this, getSupportFragmentManager(), getRIntId("realTabcontent")); leftLinearContainer.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); } if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(getRStringId("image"))); setHeaderBarCameraBackground(getResources().getDrawable(getRDrawableId("selector_camera_button"))); headerBarCamera.setTag(getResources().getString(getRStringId("image"))); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(getRStringId("images_tab")) + " "), ImageFragment.class, bundle); } else { // headerBarTitle.setText(getResources().getString(R.string.video)); // setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); // headerBarCamera.setTag(getResources().getString(R.string.video)); // // Bundle bundle = new Bundle(); // bundle.putString("name", getIntent().getStringExtra("name")); // mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { // if(MediaChooserConstants.showVideo){ // mTabHost.addTab(mTabHost.newTabSpec("tab2").setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); // } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(getRStringId("image"))); setHeaderBarCameraBackground(getResources().getDrawable(getRDrawableId("selector_camera_button"))); headerBarCamera.setTag(getResources().getString(getRStringId("image"))); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(getRStringId("images_tab")) + " "), ImageFragment.class, null); } // if(MediaChooserConstants.showVideo){ // headerBarTitle.setText(getResources().getString(R.string.video)); // setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); // headerBarCamera.setTag(getResources().getString(R.string.video)); // } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(getRColorId("tabs_title_color"))); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(getRColorId("headerbar_selected_tab_color"))); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); // VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(getRStringId("image"))); setHeaderBarCameraBackground( getResources().getDrawable(getRDrawableId("selector_camera_button"))); headerBarCamera.setTag(getResources().getString(getRStringId("image"))); if (imageFragment != null) { // if(videoFragment != null){ // fragmentTransaction.hide(videoFragment); // } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(getRColorId("headerbar_selected_tab_color"))); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { // headerBarTitle.setText(getResources().getString(R.string.video)); // setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); // headerBarCamera.setTag(getResources().getString(R.string.video)); // // if(videoFragment != null){ // // if(imageFragment != null){ // fragmentTransaction.hide(imageFragment); // } // // fragmentTransaction.show(videoFragment); // if(videoFragment.getAdapter() != null){ // videoFragment.getAdapter().notifyDataSetChanged(); // } // } // ((TextView)(mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))).setTextColor(Color.WHITE); // ((TextView)(mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))).setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); // RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); // params.height = convertDipToPixels(40); // params.width = convertDipToPixels(40); // headerBarCamera.setLayoutParams(params); // headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); // headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.nicolls.ablum.activity.HomeFragmentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); pathList = getIntent().getStringArrayListExtra("pathList"); if (pathList == null) { pathList = new ArrayList<>(); }/*from w w w . j a v a 2 s.co m*/ // Toast.makeText(this,pathList.size()+"-@@@--",Toast.LENGTH_SHORT).show(); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); headerBarCamera.setVisibility(View.GONE); if (getIntent() != null && (getIntent().getBooleanExtra("isFromBucket", false))) { if (getIntent().getBooleanExtra("image", false)) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); Bundle bundle = new Bundle(); bundle.putString("name", getIntent().getStringExtra("name")); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!!",Toast.LENGTH_SHORT).show(); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, bundle); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); Bundle bundle = new Bundle(); bundle.putStringArrayList("pathList", pathList); // Toast.makeText(this,pathList.size()+"!!!",Toast.LENGTH_SHORT).show(); bundle.putString("name", getIntent().getStringExtra("name")); mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, bundle); } } else { if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), VideoFragment.class, null); } if (MediaChooserConstants.showImage) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), ImageFragment.class, null); } if (MediaChooserConstants.showVideo) { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); } } for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { TextView textView = (TextView) mTabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(getResources().getColor(R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } if ((mTabHost.getTabWidget().getChildAt(0) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } if ((mTabHost.getTabWidget().getChildAt(1) != null)) { ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1"); VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2"); android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_camera_button)); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment != null) { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); setHeaderBarCameraBackground(getResources().getDrawable(R.drawable.selector_video_button)); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment != null) { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); if (videoFragment.getAdapter() != null) { videoFragment.getAdapter().notifyDataSetChanged(); } } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:com.andrada.sitracker.ui.fragment.DirectoryChooserFragment.java
@Override public View onCreateView(@NotNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { assert getActivity() != null; final View view = inflater.inflate(R.layout.directory_chooser, container, false); mBtnConfirm = (Button) view.findViewById(R.id.btnConfirm); Button mBtnCancel = (Button) view.findViewById(R.id.btnCancel); mBtnNavUp = (ImageButton) view.findViewById(R.id.btnNavUp); mBtnCreateFolder = (ImageButton) view.findViewById(R.id.btnCreateFolder); mTxtvSelectedFolderLabel = (TextView) view.findViewById(R.id.txtvSelectedFolderLabel); mTxtvSelectedFolder = (TextView) view.findViewById(R.id.txtvSelectedFolder); ListView mListDirectories = (ListView) view.findViewById(R.id.directoryList); if (!mIsDirectoryChooser) { mBtnConfirm.setVisibility(View.GONE); View horDivider = view.findViewById(R.id.horizontalDivider); if (horDivider != null) { horDivider.setVisibility(View.INVISIBLE); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) horDivider.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL, 0); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); horDivider.setLayoutParams(params); }//from w w w .j a v a2s. c o m } else { mBtnConfirm.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isValidFile(mSelectedDir) && mIsDirectoryChooser) { returnSelectedFolder(); } } }); } mBtnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mListener.onCancelChooser(); } }); mListDirectories.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { debug("Selected index: %d", position); if (mFilesInDir != null && position >= 0 && position < mFilesInDir.length) { changeDirectory(mFilesInDir[position]); } } }); mBtnNavUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File parent; if (mSelectedDir != null && (parent = mSelectedDir.getParentFile()) != null) { changeDirectory(parent); } } }); mBtnCreateFolder.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { openNewFolderDialog(); } }); if (!getShowsDialog()) { mBtnCreateFolder.setVisibility(View.GONE); } adjustResourceLightness(); mFilenames = new ArrayList<FileDescriptor>(); mListDirectoriesAdapter = new FolderArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, mFilenames); mListDirectories.setAdapter(mListDirectoriesAdapter); final File initialDir; if (mInitialDirectory != null && isValidFile(new File(mInitialDirectory))) { initialDir = new File(mInitialDirectory); } else { initialDir = Environment.getExternalStorageDirectory(); } changeDirectory(initialDir); return view; }
From source file:io.imoji.sdk.grid.ui.ResultView.java
public void loadCategory(String title) { int width = getDimension(5); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(width, width); int margin = getDimension(6); params.setMargins(0, margin, 0, 0);/* w ww .j a va 2 s . c om*/ params.addRule(RelativeLayout.ALIGN_PARENT_TOP); params.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(params); textView.setText(title); textView.setVisibility(VISIBLE); startResultAnimation(); }
From source file:org.loon.framework.android.game.LGameAndroid2DActivity.java
public void initialization(final boolean landscape, final boolean openAD, final Location lad, final String publisherId, final String keywords, final int requestInterval) { if (openAD) { // setVolumeControlStream(AudioManager.STREAM_MUSIC); AdManager.setPublisherId(publisherId); AdManager.setTestDevices(new String[] { "" }); AdManager.setAllowUseOfLocation(true); view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape); IHandler handler = view.getGameHandler(); RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(), handler.getHeight());/* w w w. j av a 2 s. c o m*/ if (landscape) { mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); } else { mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); } mainLayout.addView(view, mainParams); adview = new AdView(LGameAndroid2DActivity.this); if (keywords != null) { adview.setKeywords(keywords); } adview.setRequestInterval(requestInterval); adview.setGravity(Gravity.NO_GRAVITY); RelativeLayout rl = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); if (lad == Location.LEFT) { lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1); } else if (lad == Location.RIGHT) { lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); } else if (lad == Location.TOP) { lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1); } else { lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); } // adview.setVisibility(View.GONE); visible = true; frameLayout.addView(mainLayout); rl.addView(adview, lp); frameLayout.addView(rl); } else { view = new LGameAndroid2DView(LGameAndroid2DActivity.this, landscape); IHandler handler = view.getGameHandler(); RelativeLayout mainLayout = new RelativeLayout(LGameAndroid2DActivity.this); RelativeLayout.LayoutParams mainParams = new RelativeLayout.LayoutParams(handler.getWidth(), handler.getHeight()); if (landscape) { mainParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1); } else { mainParams.addRule(RelativeLayout.CENTER_IN_PARENT, 1); } mainLayout.addView(view, mainParams); frameLayout.addView(mainLayout); } if (setupSensors) { // ?? this.initSensors(); } if (view != null) { gameHandler = view.getGameHandler(); } }