Note that there are some explanatory texts on larger screens.

plurals
  1. POtextview center not working
    primarykey
    data
    text
    <p>I have a textview set up to display an integer. The range is from 0-255. The textview is right above a seekbar so I want it to always be centered. I tried the gravity center but it did not apply. I also have set the textview to show a custom font so I am not sure if this is affecting the gravity center option. With the current code the textview seems to be left justified.</p> <pre><code> &lt;TextView android:id="@+id/textViewR" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="25dp" android:layout_marginTop="10dp" android:gravity="center" android:text="255" android:textSize="37dp" android:textColor="#FF00FF00" /&gt; </code></pre> <p>I display the value</p> <pre><code> ViewGreen.setText(" " + G_value); </code></pre> <p>Here is the xml file</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" &gt; &lt;SeekBar android:id="@+id/seekBarr" android:layout_width="300dp" android:layout_height="70dp" android:layout_marginLeft="-100dp" android:layout_marginTop="180dp" android:progressDrawable="@drawable/mastersliderback" android:rotation="270" android:thumb="@drawable/imgsliderred70" /&gt; &lt;SeekBar android:id="@+id/seekBarg" android:layout_width="300dp" android:layout_height="70dp" android:layout_marginLeft="-10dp" android:layout_marginTop="180dp" android:progressDrawable="@drawable/mastersliderback" android:rotation="270" android:thumb="@drawable/imgslidergreen70" /&gt; &lt;SeekBar android:id="@+id/seekBarb" android:layout_width="300dp" android:layout_height="70dp" android:layout_marginLeft="80dp" android:layout_marginTop="180dp" android:progressDrawable="@drawable/mastersliderback" android:rotation="270" android:thumb="@drawable/imgsliderblue70" /&gt; &lt;!-- Here is the textView I am editing to make the center apply --&gt; &lt;TextView android:id="@+id/textViewR" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:layout_marginLeft="25dp" android:layout_marginTop="10dp" android:background="#FF000000" android:text="255" android:textColor="#FF00FF00" android:textSize="38dp" /&gt; &lt;TextView android:id="@+id/textViewG" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="110dp" android:layout_marginTop="10dp" android:text="255" android:textColor="#FF00FF00" android:textSize="38dp" /&gt; &lt;TextView android:id="@+id/textViewB" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="200dp" android:layout_marginTop="10dp" android:text="255" android:textColor="#FF00FF00" android:textSize="38dp" /&gt; </code></pre> <p></p> <p>Screenshot <img src="https://i.stack.imgur.com/uhUNE.png" alt="dimmer"></p> <p>Final working xml</p> <pre><code> &lt;TextView android:id="@+id/textViewR" android:layout_width="73dp" android:layout_height="wrap_content" android:layout_marginLeft="18dp" android:layout_marginTop="10dp" android:gravity="center" android:text="255" android:textColor="#FF00FF00" android:textSize="37dp" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload