List of usage examples for android.widget RelativeLayout CENTER_VERTICAL
int CENTER_VERTICAL
To view the source code for android.widget RelativeLayout CENTER_VERTICAL.
Click Source Link
From source file:at.alladin.rmbt.android.fragments.history.RMBTFilterFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); view = inflater.inflate(R.layout.history_filter, container, false); deviceListView = (LinearLayout) view.findViewById(R.id.deviceList); networkListView = (LinearLayout) view.findViewById(R.id.networkList); final RelativeLayout resultLimitView = (RelativeLayout) view.findViewById(R.id.Limit25Wrapper); limit25CheckBox = (CheckBox) view.findViewById(R.id.Limit25CheckBox); if (activity.getHistoryResultLimit() == 250) limit25CheckBox.setChecked(true); else/*from ww w .j av a 2 s.c o m*/ limit25CheckBox.setChecked(false); resultLimitView.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { if (limit25CheckBox.isChecked()) { limit25CheckBox.setChecked(false); activity.setHistoryResultLimit(0); } else { limit25CheckBox.setChecked(true); activity.setHistoryResultLimit(250); } } }); devicesToShow = activity.getHistoryFilterDevicesFilter(); networksToShow = activity.getHistoryFilterNetworksFilter(); if (devicesToShow == null && networksToShow == null) { devicesToShow = new ArrayList<String>(); networksToShow = new ArrayList<String>(); } final float scale = activity.getResources().getDisplayMetrics().density; final int leftRightItem = Helperfunctions.dpToPx(5, scale); // int topBottomItem = Helperfunctions.dpToPx(5, scale); // int leftRightDiv = Helperfunctions.dpToPx(0, scale); // int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); // int topBottomImg = Helperfunctions.dpToPx(1, scale); final String historyDevices[] = activity.getHistoryFilterDevices(); if (historyDevices != null) { for (int i = 0; i < historyDevices.length; i++) { final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); singleItemLayout.setId(i); singleItemLayout.setClickable(true); singleItemLayout.setBackgroundResource(R.drawable.list_selector); singleItemLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight); RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemTitle.setLayoutParams(layout); itemTitle.setGravity(Gravity.LEFT); itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0); itemTitle.setText(historyDevices[i]); singleItemLayout.addView(itemTitle, layout); final CheckBox itemCheck = new CheckBox(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemCheck.setLayoutParams(layout); itemCheck.setGravity(Gravity.RIGHT); itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0); itemCheck.setOnClickListener(null); itemCheck.setClickable(false); itemCheck.setId(i + historyDevices.length); if (devicesToShow.isEmpty() || devicesToShow.contains(historyDevices[i])) itemCheck.setChecked(true); else itemCheck.setChecked(false); singleItemLayout.addView(itemCheck, layout); // layout = new // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // singleItemLayout.setLayoutParams(layout); singleItemLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyDevices.length); if (check.isChecked()) { check.setChecked(false); devicesToShow.remove(historyDevices[v.getId()]); } else { check.setChecked(true); devicesToShow.add(historyDevices[v.getId()]); } } }); deviceListView.addView(singleItemLayout); final View divider = new View(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); deviceListView.addView(divider, layout); } deviceListView.invalidate(); } final String historyNetworks[] = activity.getHistoryFilterNetworks(); if (historyNetworks != null) { for (int i = 0; i < historyNetworks.length; i++) { final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); singleItemLayout.setId(i); singleItemLayout.setClickable(true); singleItemLayout.setBackgroundResource(R.drawable.list_selector); singleItemLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight); RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemTitle.setLayoutParams(layout); itemTitle.setGravity(Gravity.LEFT); itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0); itemTitle.setText(historyNetworks[i]); singleItemLayout.addView(itemTitle, layout); final CheckBox itemCheck = new CheckBox(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); layout.addRule(RelativeLayout.CENTER_VERTICAL); // itemCheck.setLayoutParams(layout); itemCheck.setGravity(Gravity.RIGHT); itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0); itemCheck.setOnClickListener(null); itemCheck.setClickable(false); itemCheck.setId(i + historyNetworks.length); if (networksToShow.isEmpty() || networksToShow.contains(historyNetworks[i])) itemCheck.setChecked(true); else itemCheck.setChecked(false); singleItemLayout.addView(itemCheck, layout); singleItemLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyNetworks.length); if (check.isChecked()) { check.setChecked(false); networksToShow.remove(historyNetworks[v.getId()]); } else { check.setChecked(true); networksToShow.add(historyNetworks[v.getId()]); } System.out.println(networksToShow.toString()); } }); networkListView.addView(singleItemLayout); final View divider = new View(activity); layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); networkListView.addView(divider, layout); } networkListView.invalidate(); } /* * // Set option as Multiple Choice. So that user can able to select * more the one option from list deviceListView.setAdapter(new * ArrayAdapter<String>(activity, * android.R.layout.simple_list_item_multiple_choice, historyDevices)); * deviceListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); * * for (int i = 0; i < historyDevices.length; i++) { * //deviceListView.setItemChecked(i, true); } * * deviceListView.setOnItemClickListener(new OnItemClickListener() { * * @Override public void onItemClick(AdapterView<?> l, View v, int * position, long id) { * * } * * }); * * * // Set option as Multiple Choice. So that user can able to select * more the one option from list networkListView.setAdapter(new * ArrayAdapter<String>(activity, * android.R.layout.simple_list_item_multiple_choice, networkDevices)); * networkListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); * * for (int i = 0; i < networkDevices.length; i++) { * networkListView.setItemChecked(i, true); } * * SparseBooleanArray checked = * deviceListView.getCheckedItemPositions(); ArrayList<String> * devicesToShow = new ArrayList<String>(); for(int i = 0; i < * checked.size()+1; i++){ if(checked.get(i)) * devicesToShow.add(historyDevices[i]); } */ return view; }
From source file:com.aniruddhc.acemusic.player.ListViewFragment.ListViewCardsAdapter.java
/** * Returns the individual row/child in the list/grid. */// w w w.j a v a 2 s .c om @Override public View getView(int position, View convertView, ViewGroup parent) { Cursor c = (Cursor) getItem(position); if (convertView == null) { convertView = LayoutInflater.from(mContext).inflate(R.layout.list_view_item, parent, false); mHolder = new ListViewHolder(); mHolder.leftImage = (ImageView) convertView.findViewById(R.id.listViewLeftIcon); mHolder.titleText = (TextView) convertView.findViewById(R.id.listViewTitleText); mHolder.subText = (TextView) convertView.findViewById(R.id.listViewSubText); mHolder.rightSubText = (TextView) convertView.findViewById(R.id.listViewRightSubText); mHolder.overflowIcon = (ImageButton) convertView.findViewById(R.id.listViewOverflow); mHolder.subTextParent = (RelativeLayout) convertView.findViewById(R.id.listViewSubTextParent); //Remove the sub text's parent layout for playlists list view. if (mListViewFragment.getFragmentId() == Common.PLAYLISTS_FRAGMENT) { mHolder.subTextParent.setVisibility(View.GONE); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mHolder.titleText .getLayoutParams(); params.addRule(RelativeLayout.CENTER_VERTICAL); mHolder.titleText.setLayoutParams(params); } mHolder.titleText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext)); mHolder.subText.setTextColor(UIElementsHelper.getSmallTextColor(mContext)); mHolder.rightSubText.setTextColor(UIElementsHelper.getSmallTextColor(mContext)); mHolder.leftImage.setImageResource(UIElementsHelper.getEmptyCircularColorPatch(mContext)); mHolder.titleText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular")); mHolder.subText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular")); mHolder.rightSubText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular")); mHolder.overflowIcon.setImageResource(UIElementsHelper.getIcon(mContext, "ic_action_overflow")); mHolder.overflowIcon.setOnClickListener(overflowClickListener); mHolder.overflowIcon.setFocusable(false); mHolder.overflowIcon.setFocusableInTouchMode(false); convertView.setTag(mHolder); } else { mHolder = (ListViewHolder) convertView.getTag(); } //Retrieve data from the cursor. String titleText = ""; String source = ""; String filePath = ""; String artworkPath = ""; String field1 = ""; String field2 = ""; String field3 = ""; String field4 = ""; String field5 = ""; try { titleText = c.getString(c.getColumnIndex(mDBColumnsMap.get(TITLE_TEXT))); source = c.getString(c.getColumnIndex(mDBColumnsMap.get(SOURCE))); filePath = c.getString(c.getColumnIndex(mDBColumnsMap.get(FILE_PATH))); artworkPath = c.getString(c.getColumnIndex(mDBColumnsMap.get(ARTWORK_PATH))); field1 = c.getString(c.getColumnIndex(mDBColumnsMap.get(FIELD_1))); field2 = c.getString(c.getColumnIndex(mDBColumnsMap.get(FIELD_2))); field3 = c.getString(c.getColumnIndex(mDBColumnsMap.get(FIELD_3))); field4 = c.getString(c.getColumnIndex(mDBColumnsMap.get(FIELD_4))); field5 = c.getString(c.getColumnIndex(mDBColumnsMap.get(FIELD_5))); } catch (NullPointerException e) { //e.printStackTrace(); } //Set the tags for this grid item. convertView.setTag(R.string.title_text, titleText); convertView.setTag(R.string.song_source, source); convertView.setTag(R.string.song_file_path, filePath); convertView.setTag(R.string.album_art, artworkPath); convertView.setTag(R.string.field_1, field1); convertView.setTag(R.string.field_2, field2); convertView.setTag(R.string.field_3, field3); convertView.setTag(R.string.field_4, field4); convertView.setTag(R.string.field_5, field5); //Set the tags for this list item's overflow button. mHolder.overflowIcon.setTag(R.string.title_text, titleText); mHolder.overflowIcon.setTag(R.string.source, source); mHolder.overflowIcon.setTag(R.string.file_path, filePath); mHolder.overflowIcon.setTag(R.string.field_1, field1); mHolder.overflowIcon.setTag(R.string.field_2, field2); mHolder.overflowIcon.setTag(R.string.field_3, field3); mHolder.overflowIcon.setTag(R.string.field_4, field4); mHolder.overflowIcon.setTag(R.string.field_5, field5); //Set the title text in the ListView. mHolder.titleText.setText(titleText); mHolder.subText.setText(field2); mHolder.rightSubText.setText(field1); //Load the album art. mApp.getPicasso().load(artworkPath).transform(new PicassoCircularTransformer()) .placeholder(UIElementsHelper.getEmptyCircularColorPatch(mContext)) .resizeDimen(R.dimen.list_view_left_icon_size, R.dimen.list_view_left_icon_size) .into(mHolder.leftImage); return convertView; }
From source file:com.dazone.crewchat.libGallery.activity.BucketHomeFragmentActivity.java
@SuppressLint("ResourceAsColor") @Override//from w ww.java 2 s. c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Instance = this; 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); headerBarTitle.setText(getResources().getString(R.string.app_name)); headerBarCamera.setBackgroundResource(R.drawable.ic_camera_unselect_from_media_chooser_header_bar); headerBarCamera.setTag(getResources().getString(R.string.image)); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); } mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), BucketVideoFragment.class, null); } if (MediaChooserConstants.showImage) { mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), BucketImageFragment.class, null); } mTabHost.getTabWidget().setBackgroundColor(getResources().getColor(R.color.tabs_color)); mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { View childView = mTabHost.getTabWidget().getChildAt(i); TextView textView = (TextView) childView.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(ContextCompat.getColor(this, R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } /* ((TextView)(mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))).setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView)(mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))).setTextColor(Color.WHITE);*/ mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { FragmentManager fragmentManager = getSupportFragmentManager(); BucketImageFragment imageFragment = (BucketImageFragment) fragmentManager.findFragmentByTag("tab1"); BucketVideoFragment videoFragment = (BucketVideoFragment) fragmentManager.findFragmentByTag("tab2"); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); headerBarCamera.setBackgroundResource(R.drawable.selector_camera_button); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment == null) { BucketImageFragment newImageFragment = new BucketImageFragment(); fragmentTransaction.add(R.id.realTabcontent, newImageFragment, "tab1"); } else { 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)); headerBarCamera.setBackgroundResource(R.drawable.selector_video_button); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment == null) { final BucketVideoFragment newVideoFragment = new BucketVideoFragment(); fragmentTransaction.add(R.id.realTabcontent, newVideoFragment, "tab2"); } else { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); } ((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.inter.trade.view.slideplayview.AbSlidingPlayView.java
/** * //from w ww .ja v a2 s. c o m * ???View * @param context * @throws */ public void initView(Context context) { this.context = context; layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); pageLineLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); //this.setBackgroundColor(Color.rgb(255, 255, 255)); RelativeLayout mRelativeLayout = new RelativeLayout(context); mViewPager = new AbInnerViewPager(context); //ViewPager,fragmentsetId()id mViewPager.setId(1985); // mPageLineLayoutParent = new LinearLayout(context); mPageLineLayoutParent.setPadding(0, 5, 0, 5); pageLineLayout = new LinearLayout(context); pageLineLayout.setPadding(15, 1, 15, 1); pageLineLayout.setVisibility(View.INVISIBLE); mPageLineLayoutParent.addView(pageLineLayout, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mRelativeLayout.addView(mViewPager, lp1); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mRelativeLayout.addView(mPageLineLayoutParent, lp2); addView(mRelativeLayout, layoutParamsFW); displayImage = AbFileUtil.getBitmapFormSrc("image/play_display.png"); hideImage = AbFileUtil.getBitmapFormSrc("image/play_hide.png"); mListViews = new ArrayList<View>(); mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews); mViewPager.setAdapter(mAbViewPagerAdapter); mViewPager.setFadingEdgeLength(0); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { makesurePosition(); onPageSelectedCallBack(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageScrolledCallBack(position); } }); }
From source file:com.admin.control.ab.AbSlidingPlayView.java
/** * ???View./*from w ww . ja v a2 s . co m*/ * * @param context the context */ public void initView(Context context) { this.context = context; //TODO >> layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); //TODO << navLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); RelativeLayout mRelativeLayout = new RelativeLayout(context); mViewPager = new AbInnerViewPager(context); //ViewPager,fragmentsetId()id // mViewPager.setId(1985); // mNavLayoutParent = new LinearLayout(context); mNavLayoutParent.setPadding(0, 5, 0, 5); navLinearLayout = new LinearLayout(context); navLinearLayout.setPadding(15, 1, 15, 1); navLinearLayout.setVisibility(View.INVISIBLE); mNavLayoutParent.addView(navLinearLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mRelativeLayout.addView(mViewPager, lp1); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mRelativeLayout.addView(mNavLayoutParent, lp2); addView(mRelativeLayout, layoutParamsFW); // addView(mRelativeLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); //? displayImage = ABFileUtil.getBitmapFromSrc("play_display.png"); hideImage = ABFileUtil.getBitmapFromSrc("play_hide.png"); mListViews = new ArrayList<>(); mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews); mViewPager.setAdapter(mAbViewPagerAdapter); mViewPager.setFadingEdgeLength(0); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { if (mAbScrolledListener != null) { if (position == 0) mAbScrolledListener.onScrollToLeft(); if (position == mListViews.size() - 1) mAbScrolledListener.onScrollToRight(); } setNowPlayIndex(position); makesurePosition(); onPageSelectedCallBack(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageScrolledCallBack(position); } }); }
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 ww .ja va 2s . c om 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); }// ww w .java 2 s .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 ww w. j a v a2 s . 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: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 2 s.c om*/ 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 a2 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)); }