List of usage examples for android.widget RelativeLayout setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:net.pocketmagic.android.carousel.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //no keyboard unless requested by user getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); // compute screen size and scaling Singleton.getInstance().InitGUIFrame(this); int padding = m_Inst.Scale(10); // create the interface : full screen container RelativeLayout panel = new RelativeLayout(this); panel.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); panel.setPadding(padding, padding, padding, padding); panel.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[] { Color.WHITE, Color.GRAY })); setContentView(panel);//w w w .j ava2 s. c o m // copy images from assets to sdcard AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma1.png", "plasma1.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma2.png", "plasma2.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma3.png", "plasma3.png", false); AppUtils.AssetFileCopy(this, "/mnt/sdcard/plasma4.png", "plasma4.png", false); //Create carousel view documents ArrayList<CarouselDataItem> Docus = new ArrayList<CarouselDataItem>(); for (int i = 0; i < 1000; i++) { CarouselDataItem docu; if (i % 4 == 0) docu = new CarouselDataItem("/mnt/sdcard/plasma1.png", 0, "First Image " + i); else if (i % 4 == 1) docu = new CarouselDataItem("/mnt/sdcard/plasma2.png", 0, "Second Image " + i); else if (i % 4 == 2) docu = new CarouselDataItem("/mnt/sdcard/plasma3.png", 0, "Third Image " + i); else docu = new CarouselDataItem("/mnt/sdcard/plasma4.png", 0, "4th Image " + i); Docus.add(docu); } // add the serach filter EditText etSearch = new EditText(this); etSearch.setHint("Search your documents"); etSearch.setSingleLine(); etSearch.setTextColor(Color.BLACK); etSearch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_menu_search, 0, 0, 0); AppUtils.AddView(panel, etSearch, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_TOP } }, -1, -1); etSearch.addTextChangedListener((TextWatcher) this); // add logo TextView tv = new TextView(this); tv.setTextColor(Color.BLACK); tv.setText("www.pocketmagic.net"); AppUtils.AddView(panel, tv, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_HORIZONTAL }, new int[] { RelativeLayout.ALIGN_PARENT_BOTTOM } }, -1, -1); // create the carousel CarouselView coverFlow = new CarouselView(this); // create adapter and specify device independent items size (scaling) // for more details see: http://www.pocketmagic.net/2013/04/how-to-scale-an-android-ui-on-multiple-screens/ m_carouselAdapter = new CarouselViewAdapter(this, Docus, m_Inst.Scale(400), m_Inst.Scale(300)); coverFlow.setAdapter(m_carouselAdapter); coverFlow.setSpacing(-1 * m_Inst.Scale(150)); coverFlow.setSelection(Integer.MAX_VALUE / 2, true); coverFlow.setAnimationDuration(1000); coverFlow.setOnItemSelectedListener((OnItemSelectedListener) this); AppUtils.AddView(panel, coverFlow, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, new int[][] { new int[] { RelativeLayout.CENTER_IN_PARENT } }, -1, -1); }
From source file:org.disrupted.rumble.userinterface.fragments.FragmentNavigationDrawer.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerFragmentLayout = (LinearLayout) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);/* ww w .j a v a2 s. c o m*/ /* set the header */ localContact = Contact.getLocalContact(); RelativeLayout header = (RelativeLayout) mDrawerFragmentLayout.findViewById(R.id.header_layout); TextView user_name = (TextView) mDrawerFragmentLayout.findViewById(R.id.header_user_name); TextView user_id = (TextView) mDrawerFragmentLayout.findViewById(R.id.header_user_id); user_name.setText(localContact.getName()); user_id.setText(localContact.getUid()); ColorGenerator generator = ColorGenerator.DEFAULT; header.setBackgroundDrawable( builder.build(localContact.getName().substring(0, 1), generator.getColor(localContact.getUid()))); /* set the navigation menu */ Resources res = getActivity().getResources(); mFirstListView = (ListView) mDrawerFragmentLayout.findViewById(R.id.navigation_first_item_list); firstList = new LinkedList<IconTextItem>(); firstList.add(new IconTextItem(R.drawable.ic_group_white_24dp, res.getString(R.string.navigation_drawer_group), 1)); firstList.add(new IconTextItem(R.drawable.ic_person_white_24dp, res.getString(R.string.navigation_drawer_contacts), 2)); firstList .add(new IconTextItem(R.drawable.ic_hashtag, res.getString(R.string.navigation_drawer_hashtag), 3)); firstList.add(new IconTextItem(R.drawable.ic_settings_applications_white_24dp, res.getString(R.string.navigation_drawer_settings), 4)); firstList.add(new IconTextItem(R.drawable.ic_close_white_24dp, res.getString(R.string.navigation_drawer_exit), 5)); mFirstListAdapter = new IconTextListAdapter(getActivity(), firstList); mFirstListView.setAdapter(mFirstListAdapter); mFirstListView.setOnItemClickListener(this); return mDrawerFragmentLayout; }