View Position In Layout
<p>Loading class (View):</p>

<pre><code>public class Loading extends View {

    private long movieStart;
    private Movie movie;

    public Loading(Context context, InputStream inputStream) {
            super(context);
        movie = Movie.decodeStream(inputStream);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        canvas.drawColor(Color.WHITE);
        super.onDraw(canvas);
        final long now = SystemClock.uptimeMillis();
        if(movieStart == 0)
            movieStart = now;
        final int relTime = (int)((now - movieStart) % movie.duration());
        movie.setTime(relTime);
        movie.draw(canvas, 100, 100);
        this.invalidate();
    }

}
</code></pre>

<p>Activity onCreate method:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    InputStream inputStream = null;
    try {
       inputStream = getAssets().open("loading.gif");
    } catch(IOException e) {
      e.printStackTrace();
    }
    Loading loading = new Loading(this, inputStream);
    setContentView(loading);
}
</code></pre>

<p>I want to set the view in center of the device layout. Like in XML layout, that we can set android:layout_centerHorizontal="true". How can I do it?</p>
