title: Set gravity of a View Programmatically
body: <p>Im working on a <code>View</code> over Android Source Code. I was wondering how can we setup multiple gravities, to a custom <code>View</code></p>
  
  <p>This is the XML</p>
  
  <pre><code>&lt;com.android.systemui.statusbar.policy.Clock
          android:id="@+id/clock"
          android:textAppearance="@style/TextAppearance.StatusBar.Clock"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:singleLine="true"
          android:paddingLeft="6dip"
          android:gravity="center_vertical|left"
          /&gt;
  </code></pre>
  
  <p>As you see, default gravity is center_vertical|left, so my Java code should be something like this</p>
  
  <pre><code>    View clock = mStatusBarView.findViewById(R.id.clock);
  
      if (clock != null) {
          SOMEHOW SET GRAVITY -&gt; mCenterClock ? Gravity.CENTER : (Gravity.CENTER_VERTICAL | Gravity.LEFT);
      }
  </code></pre>
  
  <p>setGravity method don't work on <code>View</code>. So is there an alternative of setting gravity without losing the width and height by default?.</p>
  
  <p>Thanks in advance.</p>