List of usage examples for android.widget LinearLayout VERTICAL
int VERTICAL
To view the source code for android.widget LinearLayout VERTICAL.
Click Source Link
From source file:org.apache.cordova.SplashScreenInternal.java
/** * Shows the splash screen over the full Activity *///w w w . ja va 2s . c o m @SuppressWarnings("deprecation") private void showSplashScreen(final boolean hideAfterDelay) { final int splashscreenTime = preferences.getInteger("SplashScreenDelay", 3000); final int drawableId = preferences.getInteger("SplashDrawableId", 0); // If the splash dialog is showing don't try to show it again if (this.splashDialog != null && splashDialog.isShowing()) { return; } if (drawableId == 0 || (splashscreenTime <= 0 && hideAfterDelay)) { return; } cordova.getActivity().runOnUiThread(new Runnable() { public void run() { // Get reference to display Display display = cordova.getActivity().getWindowManager().getDefaultDisplay(); Context context = webView.getContext(); // Create the layout for the dialog LinearLayout root = new LinearLayout(context); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); // TODO: Use the background color of the webview's parent instead of using the // preference. root.setBackgroundColor(preferences.getInteger("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F)); root.setBackgroundResource(drawableId); // Create and show the dialog splashDialog = new Dialog(context, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((cordova.getActivity().getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case if (hideAfterDelay) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, splashscreenTime); } } }); }
From source file:com.achep.header2actionbar.HeaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Activity activity = getActivity(); assert activity != null; mFrameLayout = new FrameLayout(activity); mHeader = onCreateHeaderView(inflater, mFrameLayout); mHeaderHeader = mHeader.findViewById(android.R.id.title); mHeaderBackground = mHeader.findViewById(android.R.id.background); assert mHeader.getLayoutParams() != null; mHeaderHeight = mHeader.getLayoutParams().height; mFakeHeader = new Space(activity); mFakeHeader.setLayoutParams(new ListView.LayoutParams(0, mHeaderHeight)); View content = onCreateContentView(inflater, mFrameLayout); if (content instanceof ListView) { isListViewEmpty = true;//from ww w . j av a 2 s . c om final ListView listView = (ListView) content; listView.addHeaderView(mFakeHeader); onSetAdapter(); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mOnScrollListener != null) { mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount); } isListViewEmpty = listView.getAdapter() == null; if (isListViewEmpty) { scrollHeaderTo(0); } else { final View child = absListView.getChildAt(0); assert child != null; scrollHeaderTo(child == mFakeHeader ? child.getTop() : -mHeaderHeight); // Log.v("header height",String.format("mHeaderHeight:%s",mHeaderHeight)); } } }); } else if (content instanceof GridView) { isListViewEmpty = true; final GridView grid = (GridView) content; //isListViewEmpty = grid.getAdapter() == null; // grid.addHeaderView(mFakeHeader); // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(grid); grid.setOnScrollListener(new AbsListView.OnScrollListener() { private ListViewScrollTracker mScrollTracker;; @Override public void onScrollStateChanged(AbsListView absListView, int scrollState) { if (mOnScrollListener != null) { mOnScrollListener.onScrollStateChanged(absListView, scrollState); } } public int getGridScrollY(GridView grid) { Method privateStringMethod = null; Integer scrollOffset = null; Integer scrollExtent = null; Integer scrollRange = null; try { privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollOffset", null); privateStringMethod.setAccessible(true); scrollOffset = (Integer) privateStringMethod.invoke(grid, null); privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollExtent", null); privateStringMethod.setAccessible(true); scrollExtent = (Integer) privateStringMethod.invoke(grid, null); privateStringMethod = GridView.class.getDeclaredMethod("computeVerticalScrollRange", null); privateStringMethod.setAccessible(true); scrollRange = (Integer) privateStringMethod.invoke(grid, null); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } return scrollRange;//scrollExtent*scrollOffset; } @Override public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (mScrollTracker == null) mScrollTracker = new ListViewScrollTracker(absListView); mScrollPosition = mScrollTracker.calculateIncrementalOffset(firstVisibleItem, visibleItemCount); Log.v("header", "scrollPosition:" + mScrollPosition); if (mOnScrollListener != null) { mOnScrollListener.onScroll(absListView, firstVisibleItem, visibleItemCount, totalItemCount); } final View child = absListView.getChildAt(0); if (child != null) { int gridScrollY = mScrollPosition;//getGridScrollY((GridView) absListView); scrollHeaderTo(-gridScrollY); //change the size of the fake header on scrolling int currentHeight = mFakeHeader.getLayoutParams().height; Integer fakeHeaderHeight = (int) (mHeaderHeight - (gridScrollY * 2)); mFakeHeader.setLayoutParams(new android.widget.LinearLayout.LayoutParams( mFakeHeader.getWidth(), fakeHeaderHeight)); // setViewTranslationY(mFrameLayout, -1*(gridScrollY)); } else scrollHeaderTo(0); } }); content = view; } else { // Merge fake header view and content view. final LinearLayout view = new LinearLayout(activity); view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); view.setOrientation(LinearLayout.VERTICAL); view.addView(mFakeHeader); view.addView(content); // Put merged content to ScrollView final NotifyingScrollView scrollView = new NotifyingScrollView(activity); scrollView.addView(view); scrollView.setOnScrollChangedListener(new NotifyingScrollView.OnScrollChangedListener() { @Override public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) { scrollHeaderTo(-t); } }); content = scrollView; } mFrameLayout.addView(content); mFrameLayout.addView(mHeader); // Content overlay view always shows at the top of content. if ((mContentOverlay = onCreateContentOverlayView(inflater, mFrameLayout)) != null) { mFrameLayout.addView(mContentOverlay, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } // Post initial scroll mFrameLayout.post(new Runnable() { @Override public void run() { scrollHeaderTo(0, true); } }); return mFrameLayout; }
From source file:com.googlecode.networklog.LogFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MyLog.d("[LogFragment] onCreateView"); LinearLayout layout = new LinearLayout(getActivity().getApplicationContext()); layout.setOrientation(LinearLayout.VERTICAL); ListView listView = new ListView(getActivity().getApplicationContext()); listView.setAdapter(adapter);/*from www.j a v a 2s . c o m*/ listView.setTextFilterEnabled(true); listView.setFastScrollEnabled(true); listView.setSmoothScrollbarEnabled(false); listView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL); listView.setStackFromBottom(true); listView.setOnItemClickListener(new CustomOnItemClickListener()); layout.addView(listView); registerForContextMenu(listView); startUpdater(); return layout; }
From source file:com.androcast.illusion.illusionmod.MainActivity.java
/** * Dialog which asks the user to enter his password * * @param password current encoded password *//*from w w w. j a v a 2s.com*/ private void askPassword(final String password) { LinearLayout linearLayout = new LinearLayout(this); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.CENTER); linearLayout.setPadding(30, 20, 30, 20); final AppCompatEditText mPassword = new AppCompatEditText(this); mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassword.setHint(getString(R.string.password)); linearLayout.addView(mPassword); new AlertDialog.Builder(this).setView(linearLayout).setCancelable(false) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { if (mPassword.getText().toString().equals(Utils.decodeString(password))) new Task().execute(); else { Utils.toast(getString(R.string.password_wrong), MainActivity.this); finish(); } } }).show(); }
From source file:it.unibs.sandroide.lib.beacon.ui.BeaconTagActivity.java
private void renderListViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.TOP);//from w w w . j a v a 2 s .c om lvBeacons = new ListView(this); lvBeacons.setId(LISTBEACONS_VIEW_ID); lvBeacons.setDivider(null); lvBeacons.setDividerHeight(0); lvTags = new ListView(this); lvTags.setId(LISTTAGS_VIEW_ID); lvTags.setVisibility(View.INVISIBLE); lvTags.setDivider(null); lvTags.setDividerHeight(0); layout.addView(lvBeacons, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); layout.addView(lvTags, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1)); setContentView(layout); }
From source file:org.mariotaku.twidere.activity.TwitterLoginActivity.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { switch (requestCode) { case REQUEST_EDIT_API: { if (resultCode == RESULT_OK) { Bundle bundle = new Bundle(); if (data != null) { bundle = data.getExtras(); }/*from w w w . j a v a 2 s .c o m*/ if (bundle != null) { mRESTBaseURL = bundle.getString(Accounts.REST_BASE_URL); mSigningRESTBaseURL = bundle.getString(Accounts.SIGNING_REST_BASE_URL); mOAuthBaseURL = bundle.getString(Accounts.OAUTH_BASE_URL); mSigningOAuthBaseURL = bundle.getString(Accounts.SIGNING_OAUTH_BASE_URL); mAuthType = bundle.getInt(Accounts.AUTH_TYPE); final boolean hide_username_password = mAuthType == Accounts.AUTH_TYPE_TWIP_O_MODE; findViewById(R.id.username_password) .setVisibility(hide_username_password ? View.GONE : View.VISIBLE); ((LinearLayout) findViewById(R.id.sign_in_sign_up)).setOrientation( hide_username_password ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL); } } setSignInButton(); break; } case REQUEST_SET_COLOR: { if (resultCode == BaseActivity.RESULT_OK) if (data != null && data.getExtras() != null) { mUserColor = data.getIntExtra(Accounts.USER_COLOR, Color.TRANSPARENT); } setUserColorButton(); break; } } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.mariotaku.twidere.fragment.support.BaseSupportListFragment.java
/** * Provide default implementation to return a simple list view. Subclasses * can override to replace with their own layout. If doing so, the returned * view hierarchy <em>must</em> have a ListView whose id is * {@link android.R.id#list android.R.id.list} and can optionally have a * sibling view id {@link android.R.id#empty android.R.id.empty} that is to * be shown when the list is empty./* ww w.j a va2s. c o m*/ * * <p> * If you are overriding this method with your own custom content, consider * including the standard layout {@link android.R.layout#list_content} in * your layout file, so that you continue to retain all of the standard * behavior of ListFragment. In particular, this is currently the only way * to have the built-in indeterminant progress state be shown. */ @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final Context context = getActivity(); final FrameLayout root = new FrameLayout(context); // ------------------------------------------------------------------ final LinearLayout pframe = new LinearLayout(context); pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID); pframe.setOrientation(LinearLayout.VERTICAL); pframe.setVisibility(View.GONE); pframe.setGravity(Gravity.CENTER); final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge); pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ final FrameLayout lframe = new FrameLayout(context); lframe.setId(INTERNAL_LIST_CONTAINER_ID); final TextView tv = new TextView(getActivity()); tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context)); tv.setId(INTERNAL_EMPTY_ID); tv.setGravity(Gravity.CENTER); lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); final ListView lv = new ListView(getActivity()); lv.setId(android.R.id.list); lv.setDrawSelectorOnTop(false); lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); // ------------------------------------------------------------------ root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return root; }
From source file:com.itraing.views.ActionSheet.java
private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);/*w ww. j a va 2 s. com*/ mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:com.kunalkene1797.blackboxkit.fragments.tools.BuildpropFragment.java
private void addKeyDialog(final String key, final String value, final boolean modify) { LinearLayout dialogLayout = new LinearLayout(getActivity()); dialogLayout.setOrientation(LinearLayout.VERTICAL); dialogLayout.setGravity(Gravity.CENTER); dialogLayout.setPadding(30, 20, 30, 20); final AppCompatEditText keyEdit = new AppCompatEditText(getActivity()); keyEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify)//w w w . j av a 2 s .co m keyEdit.setText(key.trim()); else keyEdit.setHint(getString(R.string.key)); final AppCompatEditText valueEdit = new AppCompatEditText(getActivity()); valueEdit.setTextColor(getResources().getColor(Utils.DARKTHEME ? R.color.white : R.color.black)); if (modify) valueEdit.setText(value.trim()); else valueEdit.setHint(getString(R.string.value)); dialogLayout.addView(keyEdit); dialogLayout.addView(valueEdit); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(dialogLayout) .setNegativeButton(getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }).setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (modify) overwrite(key.trim(), value.trim(), keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); else add(keyEdit.getText().toString().trim(), valueEdit.getText().toString().trim()); } }).show(); }
From source file:com.nextgis.mobile.map.RemoteTMSLayer.java
protected static void showPropertiesDialog(final MapBase map, final boolean bCreate, String layerName, String layerUrl, int type, final RemoteTMSLayer layer) { final LinearLayout linearLayout = new LinearLayout(map.getContext()); final EditText input = new EditText(map.getContext()); input.setText(layerName);/*from ww w . j a v a2 s .c o m*/ final EditText url = new EditText(map.getContext()); url.setText(layerUrl); final TextView stLayerName = new TextView(map.getContext()); stLayerName.setText(map.getContext().getString(R.string.layer_name) + ":"); final TextView stLayerUrl = new TextView(map.getContext()); stLayerUrl.setText(map.getContext().getString(R.string.layer_url) + ":"); final TextView stLayerType = new TextView(map.getContext()); stLayerType.setText(map.getContext().getString(R.string.layer_type) + ":"); final ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(map.getContext(), android.R.layout.simple_spinner_item); final Spinner spinner = new Spinner(map.getContext()); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); adapter.add(map.getContext().getString(R.string.tmstype_osm)); adapter.add(map.getContext().getString(R.string.tmstype_normal)); adapter.add(map.getContext().getString(R.string.tmstype_ngw)); if (type == TMSTYPE_OSM) { spinner.setSelection(0); } else { spinner.setSelection(1); } linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(stLayerName); linearLayout.addView(input); linearLayout.addView(stLayerUrl); linearLayout.addView(url); linearLayout.addView(stLayerType); linearLayout.addView(spinner); new AlertDialog.Builder(map.getContext()) .setTitle(bCreate ? R.string.input_layer_properties : R.string.change_layer_properties) // .setMessage(message) .setView(linearLayout).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { int tmsType = 0; switch (spinner.getSelectedItemPosition()) { case 0: case 1: tmsType = TMSTYPE_OSM; break; case 2: case 3: tmsType = TMSTYPE_NORMAL; break; } if (bCreate) { create(map, input.getText().toString(), url.getText().toString(), tmsType); } else { layer.setName(input.getText().toString()); layer.setTMSType(tmsType); map.onLayerChanged(layer); } } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. Toast.makeText(map.getContext(), R.string.error_cancel_by_user, Toast.LENGTH_SHORT).show(); } }).show(); }