Example usage for android.view Gravity TOP

List of usage examples for android.view Gravity TOP

Introduction

In this page you can find the example usage for android.view Gravity TOP.

Prototype

int TOP

To view the source code for android.view Gravity TOP.

Click Source Link

Document

Push object to the top of its container, not changing its size.

Usage

From source file:com.example.android.navigationdrawerexample.TopDrawerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_top_drawer);

    mTitle = mDrawerTitle = getTitle();/*from w  w w . j a  v  a 2  s  .  com*/
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mVerticalDrawerLayout = (VerticalDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.top_drawer);

    // set a custom shadow that overlays the main content when the drawer opens
    mVerticalDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.TOP);
    // set up the drawer's list view with items and click listener
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mPlanetTitles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());

    // enable ActionBar app icon to behave as action to toggle nav drawer
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the sliding drawer and the action bar app icon
    mVerticalDrawerToggle = new ActionBarVerticalDrawerToggle(this, /* host Activity */
            getSupportActionBar(), /* ActionBar of the hosting Activity */
            mVerticalDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.drawer_open, /* "open drawer" description for accessibility */
            R.string.drawer_close /* "close drawer" description for accessibility */
    ) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            supportInvalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };
    mVerticalDrawerToggle.setGravity(Gravity.TOP);
    mVerticalDrawerLayout.setDrawerListener(mVerticalDrawerToggle);

    if (savedInstanceState == null) {
        selectItem(0);
    }
}

From source file:biz.easymenu.easymenung.ConfirmDialog.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = li.inflate(R.layout.confirmdialog, container, false);
    ((TextView) v.findViewById(R.id.txtConfDlg)).setText(text);

    btnYes = (Button) v.findViewById(R.id.btnConfDlgYes);
    btnNo = (Button) v.findViewById(R.id.btnConfDlgNo);

    btnYes.setText(yesStr);//from w  w w. j  a va 2s .  c om
    btnNo.setText(noStr);

    WindowManager.LayoutParams WMLP = this.getDialog().getWindow().getAttributes();
    WMLP.y = 100; //y position
    WMLP.gravity = Gravity.TOP;
    WMLP.windowAnimations = R.style.PauseDialogAnimation;
    this.getDialog().getWindow().setAttributes(WMLP);
    this.getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);

    btnYes.setOnClickListener(yesListener);
    btnNo.setOnClickListener(noListener);

    return v;
}

From source file:com.github.xizzhu.simpletooltip.sample.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    findViewById(R.id.top_left_button).setOnClickListener(new View.OnClickListener() {
        @Override//  w w w.  j  av  a  2  s .  c  o  m
        public void onClick(View v) {
            showToolTipView(v, Gravity.RIGHT, "Simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.blue));
        }
    });
    findViewById(R.id.top_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.BOTTOM, "It is yet another very simple tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.green));
        }
    });
    findViewById(R.id.central_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.END, "It is a very simple tool tip in the center!",
                    ContextCompat.getColor(MainActivity.this, R.color.magenta));
        }
    });
    findViewById(R.id.bottom_left_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.TOP, "Tool tip, once more!",
                    ContextCompat.getColor(MainActivity.this, R.color.maroon));
        }
    });
    findViewById(R.id.bottom_right_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipView(v, Gravity.LEFT, "Magical tool tip!",
                    ContextCompat.getColor(MainActivity.this, R.color.navy));
        }
    });

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showToolTipViewWithParent((Button) v, Gravity.BOTTOM);
        }
    };
    findViewById(R.id.button1).setOnClickListener(listener);
    findViewById(R.id.button2).setOnClickListener(listener);
    findViewById(R.id.button3).setOnClickListener(listener);
    findViewById(R.id.button4).setOnClickListener(listener);
    findViewById(R.id.button5).setOnClickListener(listener);
    findViewById(R.id.button6).setOnClickListener(listener);
    findViewById(R.id.button7).setOnClickListener(listener);

    showToolTipView(findViewById(R.id.central_button), Gravity.START, "A simple tool tip!",
            ContextCompat.getColor(MainActivity.this, R.color.magenta), 750L);
}

From source file:am.project.x.business.drawables.linedrawable.LineDrawableActivity.java

@SuppressLint("RtlHardcoded")
@Override/*from w  w  w  .j  ava  2 s  . c  om*/
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    switch (position) {
    default:
    case 0:
        drawable.setGravity(Gravity.BOTTOM);
        break;
    case 1:
        drawable.setGravity(Gravity.LEFT);
        break;
    case 2:
        drawable.setGravity(Gravity.TOP);
        break;
    case 3:
        drawable.setGravity(Gravity.RIGHT);
        break;
    case 4:
        drawable.setGravity(Gravity.CENTER_HORIZONTAL);
        break;
    case 5:
        drawable.setGravity(Gravity.CENTER_VERTICAL);
        break;
    case 6:
        drawable.setGravity(Gravity.TOP | Gravity.BOTTOM);
        break;
    case 7:
        drawable.setGravity(Gravity.LEFT | Gravity.RIGHT);
        break;
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.PhoneStateObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//from w  w w .j  a  v  a 2s.co  m
    TextView valueTV = new TextView(context);
    valueTV.setText(asText(content));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    frame.addView(valueTV);
}

From source file:com.example.android.swiperefreshlistfragment.tests.SampleTests.java

/**
 * Test that swiping on the populated list triggers a refresh.
 *///from  w w w . j a va  2 s.c o  m
public void testSwipingListView() {
    // Given a SwipeRefreshLayout which is displaying a populated list

    // When the swipe refresh layout is dragged
    TouchUtils.dragViewBy(this, mSwipeRefreshLayout, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0,
            Math.round(mSwipeRefreshLayout.getHeight() * 0.4f));

    // Then the SwipeRefreshLayout should be refreshing
    // We need to use runOnMainSync here as fake dragging uses waitForIdleSync()
    getInstrumentation().runOnMainSync(new Runnable() {
        @Override
        public void run() {
            assertTrue(mSwipeRefreshLayout.isRefreshing());
        }
    });
}

From source file:com.longle1.facedetection.TimedAsyncHttpResponseHandler.java

@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
    Log.i("RTT", String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms");
    String msg = "RTT: " + String.format("%.1f", (System.nanoTime() - startTime) / 1e6) + " ms";
    Toast mToast = Toast.makeText(mContext, msg, Toast.LENGTH_SHORT);
    mToast.setGravity(Gravity.TOP, 0, 0);
    mToast.show();/*ww w.  java  2 s  . c o m*/
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.StatusObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();//  ww  w.  j ava 2 s. c o  m
    TextView valueTV = new TextView(context);
    valueTV.setText(content.optString(TEXT));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    if (Linkify.addLinks(valueTV, Linkify.ALL)) {
        if (!allowInteractions)
            valueTV.setMovementMethod(null);
    }

    frame.addView(valueTV);
}

From source file:com.smart.able2include.SimpleTextOverlayView.java

private void createView() {
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT);/* w  w  w.j  ava  2s.c o m*/

    params.gravity = Gravity.START | Gravity.TOP;
    params.x = 0;
    params.y = 30;
    params.width = wm.getDefaultDisplay().getWidth();
    params.height = wm.getDefaultDisplay().getHeight() - 30;

    frameLayout = new RelativeLayout(mServiceContext);
    LayoutInflater layoutInflater = (LayoutInflater) mServiceContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    // Here is the place where you can inject whatever layout you want.
    layoutInflater.inflate(R.layout.simpletxt_layout, frameLayout);

    TextView text = (TextView) frameLayout.findViewById(R.id.textViewSimplifiedText);
    text.setText(mSimpleText);
    dialogButton = (Button) frameLayout.findViewById(R.id.simpleButtonOK);
    // if button is clicked, close the custom dialog
    dialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            RemoveOvelay();
            delegate.onClick();
        }
    });
    synchronized (mSyncToken) {
        wm.addView(frameLayout, params);
        mOnTop = true;
    }
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.IMObj.java

public void render(Context context, ViewGroup frame, Obj obj, boolean allowInteractions) {
    JSONObject content = obj.getJson();/*from w w  w.ja  v a2s .  c  o  m*/
    TextView valueTV = new TextView(context);
    valueTV.setText("IM:" + content.optString(TEXT));
    valueTV.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    valueTV.setGravity(Gravity.TOP | Gravity.LEFT);
    frame.addView(valueTV);
}